import pandas as pd
from openpyxl import load_workbook
from openpyxl.styles import Font, Alignment, PatternFill
import datetime
import os
import shutil
import openpyxl
import sys

# 添加数据处理模块导入
# 获取当前文件所在目录
current_dir = os.path.dirname(os.path.abspath(__file__))
backend_dir = os.path.dirname(current_dir)
utils_dir = os.path.join(backend_dir, "utils")
sys.path.extend([backend_dir, utils_dir])

# 从utils目录导入数据处理模块
from utils.data_processor import save_fault_details_to_database, save_fault_data_to_database, save_fault_description_to_database

def modify_excel_file(file_path):
    """
    修改Excel文件的主要功能函数，步骤如下：
    1. 更新特定列（如计数）。
    2. 格式化日期列。
    3. 应用样式（表头、对齐方式）。
    4. 添加批注。
    
    参数:
        file_path (str): 输入Excel文件的路径。
    
    返回:
        str: 修改后的Excel文件路径。
    """
    try:
        # 检查文件是否存在
        if not os.path.exists(file_path):
            raise FileNotFoundError(f"文件未找到: {file_path}")

        # ==================== 1. 使用pandas读取并修改数据 ====================
        print(f"开始处理网络云运维日报故障处理上报Excel文件: {file_path}")
        
        # 读取Excel文件，跳过第一行，使用第二行作为列名
        df = pd.read_excel(file_path, header=1)
        #列名只显示到故障板件SN号，不需要显示'Unnamed: 13', 'Unnamed: 14', 'Unnamed: 15', 'Unnamed: 16', 'Unnamed: 17', 'Unnamed: 18', 'Unnamed: 19', 'Unnamed: 20', 'Unnamed: 21', 'Unnamed: 22', 'Unnamed: 23', 'Unnamed: 24'
        print("当前文件的列名（使用第二行作为列名）：", [col for col in df.columns.tolist() if not col.startswith('Unnamed') and ('故障板件SN号' not in col or col == '故障板件SN号')])
        
        # 检查必需的列是否存在（替换为实际列名）
        required_columns = ['所属期次','所属资源池','设备归属类别','设备厂家','板件种类','是否国产']  # 替换为实际列名
        for col in required_columns:
            if col not in df.columns:
                raise ValueError(f"文件缺少必需的列：{col}")
        
        # 故障数量统计（使用字典来存储计数器，更简洁且易于管理）
        counters = {
            'd52': 0, 'd53': 0, 'd54': 0, 'd55': 0, 'd56': 0,
            'd57': 0, 'd58': 0, 'd59': 0, 'd60': 0, 'd61': 0,
            'd62': 0, 'd63': 0, 'd64': 0, 'd65': 0, 'd66': 0,
            'd67': 0, 'd68': 0, 'd69': 0, 
            'the_first_phase':0,'the_second_phase':0, 'the_third_phase':0,
            'the_fourth_phase':0
            }
        #故障厂家数统计（使用字典来存储计数器，更简洁且易于管理）
        counters1= {
            'd70': 0, 'd71': 0, 'd72': 0, 'd73': 0, 'd74': 0,
            'd75': 0, 'd76': 0, 'd77': 0, 'd78': 0, 'd79': 0,
            'd80': 0, 'd81': 0, 'd82': 0, 'd83': 0, 'd84': 0,
            'd85': 0, 'd86': 0, 'd87': 0, 'd88': 0, 'd89': 0,
            'd90': 0, 'd91': 0, 'd92': 0, 'd93': 0, 'd94': 0,
            'd95': 0, 'd96': 0, 'd97': 0, 'd98': 0, 'd99': 0,
            'd100': 0, 'd101': 0, 'd102': 0, 'd103': 0, 'd104': 0,
            'd105': 0, 'd106': 0, 'd107': 0, 'd108': 0, 'd109': 0,
            'd110': 0, 'd111': 0, 'd112': 0, 'd113': 0, 'd114': 0,
            'd115': 0, 'd116': 0, 'd117': 0, 'd118': 0, 'd119': 0,
            'd120': 0, 'd121': 0, 'd122': 0, 'd123': 0, 'd124': 0,
            'd125': 0, 'd126': 0, 'd127': 0, 'd128': 0, 'd129': 0,
            'd130': 0, 'd131': 0, 'd132': 0, 'd133': 0, 'd134': 0,  
            'd135': 0, 'd136': 0, 'd137': 0, 'd138': 0, 'd139': 0,  
            'd140': 0, 'd141': 0, 'd142': 0, 'd143': 0, 'd144': 0,  
            'd145': 0, 'd146': 0, 'd147': 0, 'd148': 0, 'd149': 0,  
            'd150': 0, 'd151': 0, 'd152': 0, 'd153': 0, 'd154': 0,  
            'd155': 0, 'd156': 0, 'd157': 0, 'd158': 0, 'd159': 0,  
            'd160': 0, 'd161': 0, 'd162': 0, 'd163': 0, 'd164': 0,    
            'd165': 0, 'd166': 0, 'd167': 0, 'd168': 0, 'd169': 0,
            'd170': 0, 'd171': 0, 'd172': 0, 'd173': 0, 'd174': 0,
            'd175': 0, 'd176': 0, 'd177': 0, 'd178': 0, 'd179': 0,
            'd180': 0, 'd181': 0, 'd182': 0, 'd183': 0, 'd184': 0,
            'd185': 0, 'd186': 0, 'd187': 0, 'd188': 0, 'd189': 0,  'd190': 0, 'd191': 0,
            'h3c_storage':0,'xfusion_computer':0,'huawei_storage':0,'zte_computer':0,'zte_storage':0,
            'inspur_computer':0,'inspur_storage':0
            }
        #详细故障描述（使用字典来存储计数器，更简洁且易于管理）
        #1期
        #dmz浪潮计算
        counters3 = {
            'f70': 0, 'f71': 0, 'f72': 0, 'f73': 0, 'f74': 0,               
            'f75': 0, 'f76': 0, 'f77': 0, 'f78': 0, 'f79': 0,
            'f80': 0, 'f81': 0, 'f82': 0, 'f83': 0, 'f84': 0,
            'f85': 0, 'sum_inspur_computer_dmz': 0
               }
        #可信1浪潮计算
        counters4 = {
            'g70': 0, 'g71': 0, 'g72': 0, 'g73': 0, 'g74': 0,               
            'g75': 0, 'g76': 0, 'g77': 0, 'g78': 0, 'g79': 0,
            'g80': 0, 'g81': 0, 'g82': 0, 'g83': 0, 'g84': 0,
            'g85': 0, 'sum_inspur_computer_trust1': 0
               }
        #可信2浪潮计算
        counters5 = {
            'h70': 0, 'h71': 0, 'h72': 0, 'h73': 0, 'h74': 0,               
            'h75': 0, 'h76': 0, 'h77': 0, 'h78': 0, 'h79': 0,
            'h80': 0, 'h81': 0, 'h82': 0, 'h83': 0, 'h84': 0,
            'h85': 0, 'sum_inspur_computer_trust2': 0
               }
        #dmz华为存储
        counters6 = {
            'i70': 0, 'i71': 0, 'i72': 0, 'i73': 0, 'i74': 0,               
            'i75': 0, 'i76': 0, 'i77': 0, 'i78': 0, 'i79': 0,
            'i80': 0, 'i81': 0, 'i82': 0, 'i83': 0, 'i84': 0,
            'i85': 0, 'sum_huawei_storage_dmz': 0
               }
        #可信1华为存储
        counters7 = {
            'j70': 0, 'j71': 0, 'j72': 0, 'j73': 0, 'j74': 0,               
            'j75': 0, 'j76': 0, 'j77': 0, 'j78': 0, 'j79': 0,
            'j80': 0, 'j81': 0, 'j82': 0, 'j83': 0, 'j84': 0,
            'j85': 0, 'sum_huawei_storage_trust1': 0
               }
        #可信2中兴存储
        counters8 = {
            'k70': 0, 'k71': 0, 'k72': 0, 'k73': 0, 'k74': 0,               
            'k75': 0, 'k76': 0, 'k77': 0, 'k78': 0, 'k79': 0,
            'k80': 0, 'k81': 0, 'k82': 0, 'k83': 0, 'k84': 0,
            'k85': 0, 'sum_zte_storage_trust2': 0
               }
        #2期
        #新华三
        counters2 = {
            'e70': 0, 'e71': 0, 'e72': 0, 'e73': 0, 'e74': 0,
            'e75': 0, 'e76': 0, 'e77': 0, 'e78': 0, 'e79': 0,
            'e80': 0, 'e81': 0, 'e82': 0, 'e83': 0, 'e84': 0,
            'e85': 0, 'sum2_h3': 0
               }
        #超聚变
        counters9 = {
            'l70': 0, 'l71': 0, 'l72': 0, 'l73': 0, 'l74': 0,
            'l75': 0, 'l76': 0, 'l77': 0, 'l78': 0, 'l79': 0,
            'l80': 0, 'l81': 0, 'l82': 0, 'l83': 0, 'l84': 0,
            'l85': 0, 'sum2_xfusion_computer_dmz': 0
               }
        counters10 = {
            'm70': 0, 'm71': 0, 'm72': 0, 'm73': 0, 'm74': 0,
            'm75': 0, 'm76': 0, 'm77': 0, 'm78': 0, 'm79': 0,
            'm80': 0, 'm81': 0, 'm82': 0, 'm83': 0, 'm84': 0,
            'm85': 0, 'sum2_xfusion_computer_trust1': 0
              }
        counters11 = {
            'n70': 0, 'n71': 0, 'n72': 0, 'n73': 0, 'n74': 0,
            'n75': 0, 'n76': 0, 'n77': 0, 'n78': 0, 'n79': 0,
            'n80': 0, 'n81': 0, 'n82': 0, 'n83': 0, 'n84': 0,
            'n85': 0, 'sum2_xfusion_computer_trust2': 0
               }
        counters12 = {
            'o70': 0, 'o71': 0, 'o72': 0, 'o73': 0, 'o74': 0,
            'o75': 0, 'o76': 0, 'o77': 0, 'o78': 0, 'o79': 0,
            'o80': 0, 'o81': 0, 'o82': 0, 'o83': 0, 'o84': 0,
            'o85': 0,'sum2_xfusion_computer_trust3': 0
               }
        counters13 = {
            'p70': 0, 'p71': 0, 'p72': 0, 'p73': 0, 'p74': 0,
            'p75': 0, 'p76': 0, 'p77': 0, 'p78': 0, 'p79': 0,
            'p80': 0, 'p81': 0, 'p82': 0, 'p83': 0, 'p84': 0,
            'p85': 0,'sum2_xfusion_computer_trust4': 0
               }
        counters14 = {
            'q70': 0, 'q71': 0, 'q72': 0, 'q73': 0, 'q74': 0,
            'q75': 0, 'q76': 0, 'q77': 0, 'q78': 0, 'q79': 0,
            'q80': 0, 'q81': 0, 'q82': 0, 'q83': 0, 'q84': 0,
            'q85': 0,'sum2_xfusion_computer_trust5': 0
               }
        counters15 = {
            'r70': 0, 'r71': 0, 'r72': 0, 'r73': 0, 'r74': 0,
            'r75': 0, 'r76': 0, 'r77': 0, 'r78': 0, 'r79': 0,
            'r80': 0, 'r81': 0, 'r82': 0, 'r83': 0, 'r84': 0,
            'r85': 0,'sum2_xfusion_computer_wg6': 0
               }
        #华为存储
        counters16 = {
            's70': 0, 's71': 0, 's72': 0, 's73': 0, 's74': 0,
            's75': 0, 's76': 0, 's77': 0, 's78': 0, 's79': 0,
            's80': 0, 's81': 0, 's82': 0, 's83': 0, 's84': 0,
            's85': 0,'sum2_huawei_storage_dmz': 0
               }
        counters17 = {
            't70': 0, 't71': 0, 't72': 0, 't73': 0, 't74': 0,
            't75': 0, 't76': 0, 't77': 0, 't78': 0, 't79': 0,
            't80': 0, 't81': 0, 't82': 0, 't83': 0, 't84': 0,
            't85': 0,'sum2_huawei_storage_trust1': 0
               }
        counters18 = {
            'u70': 0, 'u71': 0, 'u72': 0, 'u73': 0, 'u74': 0,
            'u75': 0, 'u76': 0, 'u77': 0, 'u78': 0, 'u79': 0,
            'u80': 0, 'u81': 0, 'u82': 0, 'u83': 0, 'u84': 0,
            'u85': 0,'sum2_huawei_storage_trust3': 0
               }
        counters19 = {
            'v70': 0, 'v71': 0, 'v72': 0, 'v73': 0, 'v74': 0,
            'v75': 0, 'v76': 0, 'v77': 0, 'v78': 0, 'v79': 0,
            'v80': 0, 'v81': 0, 'v82': 0, 'v83': 0, 'v84': 0,
            'v85': 0,'sum2_huawei_storage_trust4': 0
               }
        #中兴存储
        counters20 = {
            'w70': 0, 'w71': 0, 'w72': 0, 'w73': 0, 'w74': 0,
            'w75': 0, 'w76': 0, 'w77': 0, 'w78': 0, 'w79': 0,
            'w80': 0, 'w81': 0, 'w82': 0, 'w83': 0, 'w84': 0,
            'w85': 0,'sum2_zte_storage_trust2': 0
               }
        #浪潮存储
        counters21 = {
            'x70': 0, 'x71': 0, 'x72': 0, 'x73': 0, 'x74': 0,
            'x75': 0, 'x76': 0, 'x77': 0, 'x78': 0, 'x79': 0,
            'x80': 0, 'x81': 0, 'x82': 0, 'x83': 0, 'x84': 0,
            'x85': 0,'sum2_inspur_storage_trust5': 0
               }
        #3期=========================================================
        #中兴计算
        counters22 = {
            'ee70': 0, 'ee71': 0, 'ee72': 0, 'ee73': 0, 'ee74': 0,
            'ee75': 0, 'ee76': 0, 'ee77': 0, 'ee78': 0, 'ee79': 0,
            'ee80': 0, 'ee81': 0, 'ee82': 0, 'ee83': 0, 'ee84': 0,
            'ee85': 0, 'sum3_zte_computer_dmz': 0
               }
        counters23 = {
            'ff70': 0, 'ff71': 0, 'ff72': 0, 'ff73': 0, 'ff74': 0,
            'ff75': 0, 'ff76': 0, 'ff77': 0, 'ff78': 0, 'ff79': 0,
            'ff80': 0, 'ff81': 0, 'ff82': 0, 'ff83': 0, 'ff84': 0,
            'ff85': 0, 'sum3_zte_computer_trust2': 0
               }
        counters24 = {
            'gg70': 0, 'gg71': 0, 'gg72': 0, 'gg73': 0, 'gg74': 0,
            'gg75': 0, 'gg76': 0, 'gg77': 0, 'gg78': 0, 'gg79': 0,
            'gg80': 0, 'gg81': 0, 'gg82': 0, 'gg83': 0, 'gg84': 0,
            'gg85': 0, 'sum3_zte_computer_trust4': 0
               }
        counters25 = {
            'hh70': 0, 'hh71': 0, 'hh72': 0, 'hh73': 0, 'hh74': 0,
            'hh75': 0, 'hh76': 0, 'hh77': 0, 'hh78': 0, 'hh79': 0,
            'hh80': 0, 'hh81': 0, 'hh82': 0, 'hh83': 0, 'hh84': 0,
            'hh85': 0, 'sum3_zte_computer_trust5': 0
               }
        counters26 = {
            'ii70': 0, 'ii71': 0, 'ii72': 0, 'ii73': 0, 'ii74': 0,
            'ii75': 0, 'ii76': 0, 'ii77': 0, 'ii78': 0, 'ii79': 0,
            'ii80': 0, 'ii81': 0, 'ii82': 0, 'ii83': 0, 'ii84': 0,
            'ii85': 0, 'sum3_zte_computer_wg6': 0
               }
        #中兴存储
        counters27 = {
            'jj70': 0, 'jj71': 0, 'jj72': 0, 'jj73': 0, 'jj74': 0,
            'jj75': 0, 'jj76': 0, 'jj77': 0, 'jj78': 0, 'jj79': 0,
            'jj80': 0, 'jj81': 0, 'jj82': 0, 'jj83': 0, 'jj84': 0,
            'jj85': 0, 'sum3_zte_storage_trust2': 0
               }
        counters28 = {
            'kk70': 0, 'kk71': 0, 'kk72': 0, 'kk73': 0, 'kk74': 0,
            'kk75': 0, 'kk76': 0, 'kk77': 0, 'kk78': 0, 'kk79': 0,
            'kk80': 0, 'kk81': 0, 'kk82': 0, 'kk83': 0, 'kk84': 0,
            'kk85': 0, 'sum3_zte_storage_trust7': 0
               }
        #新华三存储
        counters29 = {
            'll70': 0, 'll71': 0, 'll72': 0, 'll73': 0, 'll74': 0,
            'll75': 0, 'll76': 0, 'll77': 0, 'll78': 0, 'll79': 0,
            'll80': 0, 'll81': 0, 'll82': 0, 'll83': 0, 'll84': 0,
            'll85': 0, 'sum3_h3c_storage_wg6': 0
               }
        #浪潮计算
        counters30 = {
            'mm70': 0, 'mm71': 0, 'mm72': 0, 'mm73': 0, 'mm74': 0,
            'mm75': 0, 'mm76': 0, 'mm77': 0, 'mm78': 0, 'mm79': 0,
            'mm80': 0, 'mm81': 0, 'mm82': 0, 'mm83': 0, 'mm84': 0,
            'mm85': 0, 'sum3_inspur_computer_wg6': 0
               }
        
        counters31 = {
            'nn70': 0, 'nn71': 0, 'nn72': 0, 'nn73': 0, 'nn74': 0,
            'nn75': 0, 'nn76': 0, 'nn77': 0, 'nn78': 0, 'nn79': 0,
            'nn80': 0, 'nn81': 0, 'nn82': 0, 'nn83': 0, 'nn84': 0,
            'nn85': 0, 'sum3_inspur_computer_trust7': 0
               }
        #浪潮存储
        counters32 = {
            'oo70': 0, 'oo71': 0, 'oo72': 0, 'oo73': 0, 'oo74': 0,
            'oo75': 0, 'oo76': 0, 'oo77': 0, 'oo78': 0, 'oo79': 0,
            'oo80': 0, 'oo81': 0, 'oo82': 0, 'oo83': 0, 'oo84': 0,
            'oo85': 0, 'sum3_inspur_storage_trust5': 0
               }
        #4期=========================================================
        #中兴计算
        counters33 = {
            'pp70': 0, 'pp71': 0, 'pp72': 0, 'pp73': 0, 'pp74': 0,
            'pp75': 0, 'pp76': 0, 'pp77': 0, 'pp78': 0, 'pp79': 0,
            'pp80': 0, 'pp81': 0, 'pp82': 0, 'pp83': 0, 'pp84': 0,
            'pp85': 0, 'sum4_zte_computer_wg6': 0
               }
        counters34 = {
            'qq70': 0, 'qq71': 0, 'qq72': 0, 'qq73': 0, 'qq74': 0,
            'qq75': 0, 'qq76': 0, 'qq77': 0, 'qq78': 0, 'qq79': 0,
            'qq80': 0, 'qq81': 0, 'qq82': 0, 'qq83': 0, 'qq84': 0,
            'qq85': 0, 'sum4_zte_computer_trust8': 0
               }
        #浪潮存储
        counters35 = {
            'rr70': 0, 'rr71': 0, 'rr72': 0, 'rr73': 0, 'rr74': 0,
            'rr75': 0, 'rr76': 0, 'rr77': 0, 'rr78': 0, 'rr79': 0,
            'rr80': 0, 'rr81': 0, 'rr82': 0, 'rr83': 0, 'rr84': 0,
            'rr85': 0, 'sum4_inspur_storage_trust8': 0
               }

        # 初始化计数器
        total_devices = 0
        # 存储故障明细数据的列表
        fault_details = []
        
        #轮询表格
        for index, row in df.iterrows():

            # 将板件种类中的CPU统一转换为小写cpu，确保后续判断不区分大小写
            # 首先检查板件种类是否为字符串类型，避免非字符串类型报错
            # 然后统一转为大写后比较，实现不区分大小写的判断
            if isinstance(row['板件种类'], str) and row['板件种类'].upper() == 'CPU':
                # 将CPU统一修改为小写cpu，保持数据一致性
                row['板件种类'] = 'cpu'
                
            if isinstance(row['所属资源池'], str) and row['所属资源池'].upper() == 'DMZ':
                # 将dmz统一修改为小写dmz，保持数据一致性
                row['所属资源池'] = 'dmz'

            if row['板件种类'] not in ['光模块', '内存', '缓存盘', '背板', '传感器', 'RISER卡', '主板', '电源', '尾纤', '整机', '硬盘', 'cpu', '网卡', 'PCIE卡', 'raid卡', '风扇']:
               continue

            # 检查'故障设备名称'是否为空，作为遍历终止条件
            if pd.isna(row['故障设备名称']):
                print(f"遍历结束，共处理了 {total_devices} 个故障设备", flush=True)
                break
            
            # 打印当前行的设备名称明细
            device_name = str(row['故障设备名称']).strip()
            print(f"故障设备名称明细[{index}]: {device_name}")
            total_devices += 1
            
            # 收集故障明细数据
            fault_detail = (
                '',  # serial_number (序号)
                device_name,  # device_name (故障设备名称)
                row.get('所属资源池', ''),  # resource_pool (所属资源池)
                # 获取当前行的"所属资源池"列的值，如果该列不存在则返回空字符串
                # row.get()方法用于安全地获取pandas DataFrame行中的列值
                # 第一个参数'所属资源池'是列名，第二个参数''是默认值（当列不存在时返回）
                row.get('所属期次', ''),  # phase (所属期次)
                row.get('故障发生时间', ''),  # fault_time (故障发生时间)
                row.get('告警清除时间', ''),  # alarm_clear_time (告警清除时间)
                row.get('设备归属类别', ''),  # device_category (设备归属类别)
                row.get('设备厂家', ''),  # manufacturer (设备厂家)
                row.get('板件种类', ''),  # component_type (板件种类)
                row.get('发现方式（集团工单/巡检）', ''),  # discovery_method (发现方式)
                row.get('解决记录', ''),  # solution_record (解决记录)
                row.get('是否国产', ''),  # is_domestic (是否国产)
                row.get('故障板件SN号', '')  # component_sn (故障板件SN号)
            )
            fault_details.append(fault_detail)
            
            # 1.1:故障数量统计-------------------------
            #1期
            if  row['所属期次'] == '1期': 
                if row['所属资源池'] == 'dmz':
                    counters['d52'] += 1
                elif row['所属资源池'] == '可信1':
                    counters['d53'] += 1
                elif row['所属资源池'] == '可信2':
                    counters['d54'] += 1
            #2期
            elif row['所属期次'] == '2期':
                if row['所属资源池'] == 'dmz':
                    counters['d55'] += 1
                elif row['所属资源池'] == '可信1':
                    counters['d56'] += 1
                elif row['所属资源池'] == '可信2':
                    counters['d57'] += 1
                elif row['所属资源池'] == '可信3':
                    counters['d58'] += 1
                elif row['所属资源池'] == '可信4':
                    counters['d59'] += 1    
                elif row['所属资源池'] == '可信5':
                    counters['d60'] += 1
                elif row['所属资源池'] == '网管6' :
                    counters['d61'] += 1
            #3期
            elif row['所属期次'] == '3期':         
                if row['所属资源池'] == 'dmz':
                    counters['d62'] += 1
                elif row['所属资源池'] == '可信2':
                    counters['d63'] += 1
                elif row['所属资源池'] == '可信4':
                    counters['d64'] += 1
                elif row['所属资源池'] == '可信5':
                    counters['d65'] += 1
                elif row['所属资源池'] == '网管6':
                    counters['d66'] += 1
                elif row['所属资源池'] == '可信7':
                    counters['d67'] += 1
            #4期
            elif row['所属期次'] == '4期':         
                if row['所属资源池'] == '可信8':
                    counters['d68'] += 1
                elif row['所属资源池'] == '网管6':
                    counters['d69'] += 1
        

            # 2.1：故障厂家数统计（品牌）---------------------------------------------																			 
            if  row['设备厂家'] == '新华三' and row['板件种类'] == '硬盘' and row['是否国产'] == '否': #新华三硬盘
                counters1['d70'] += 1
            elif  row['设备厂家'] == '新华三' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '否':
                counters1['d71'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '网卡' and row['是否国产'] == '否':
                counters1['d72'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == 'PCIE卡' and row['是否国产'] == '否':       
                counters1['d73'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == 'raid卡' and row['是否国产'] == '否':       
                counters1['d74'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '风扇' and row['是否国产'] == '否':       
                counters1['d75'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '光模块' :       
                counters1['d76'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '内存':       
                counters1['d77'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '缓存盘' :       
                counters1['d78'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '背板' :       
                counters1['d79'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '传感器' :       
                counters1['d80'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == 'RISER卡' :       
                counters1['d81'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '主板' :       
                counters1['d82'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '电源' :       
                counters1['d83'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '尾纤' :       
                counters1['d84'] += 1
            elif  row['设备厂家'] == '新华三' and row['板件种类'].strip() == '整机':
                counters1['d85'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '否':     #超聚变  。5期需要考虑超聚变国产化ARM CPU
                counters1['d86'] += 1
            elif  row['设备厂家'] == '超聚变' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '否':       
                counters1['d87'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '网卡' and row['是否国产'] == '否':       
                counters1['d88'] += 1   
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == 'raid卡' and row['是否国产'] == '否':       
                counters1['d89'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '风扇':       
                counters1['d90'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == 'PCIE卡':       
                counters['d91'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '光模块' :       
                counters1['d92'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '内存' :       
                counters1['d93'] += 1                
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '缓存盘' :       
                counters1['d94'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '背板' :       
                counters1['d95'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '传感器' :       
                counters1['d96'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == 'RISER卡' :       
                counters1['d97'] += 1    
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '主板' :       
                counters1['d98'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '电源' :       
                counters1['d99'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '尾纤' :       
                counters1['d100'] += 1
            elif  row['设备厂家'] == '超聚变' and row['板件种类'].strip() == '整机':
                counters1['d101'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '否':     #华为存储 
                counters1['d102'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == 'cpu' :      
                counters1['d103'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '网卡' :     
                counters1['d104'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == 'PCIE卡' :     
                counters1['d105'] += 1       
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == 'raid卡':    
                counters1['d106'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '风扇' :     
                counters1['d107'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '光模块' :     
                counters1['d108'] += 1               
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '内存' :     
                counters1['d109'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '缓存盘' :     
                counters1['d110'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '背板' :     
                counters1['d111'] += 1           
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '传感器' :     
                counters1['d112'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == 'RISER卡' :     
                counters1['d113'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '主板' :     
                counters1['d114'] += 1                                           
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '电源' :     
                counters1['d115'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '尾纤' :      
                counters1['d116'] += 1
            elif  row['设备厂家'] == '华为' and row['板件种类'].strip() == '整机':      
                counters1['d117'] += 1
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '否':     #中兴计算 
                counters1['d118'] += 1       
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '否':
                counters1['d119'] += 1
            #新增可信8中兴计算cpu为海光3判断规则20250808
            #elif  row['所属资源池']=='可信8' and row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '是':
                #counters1['d191'] += 1       
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '网卡' and row['是否国产'] == '否':
                counters1['d120'] += 1       
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == 'PCIE卡' and row['是否国产'] == '否':
                counters1['d121'] += 1          
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == 'raid卡' and row['是否国产'] == '否':
                counters1['d122'] += 1          
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '是':
                counters1['d123'] += 1       
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '是':
                counters1['d124'] += 1               
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '风扇' :     
                counters1['d125'] += 1
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '光模块' :     
                counters1['d126'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '内存' :     
                counters1['d127'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '缓存盘' :      
                counters1['d128'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '背板' :      
                counters1['d129'] += 1                                                                     
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '传感器' :      
                counters1['d130'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == 'RISER卡' :    
                counters1['d131'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '主板' :     
                counters1['d132'] += 1                
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '电源' :      
                counters1['d133'] += 1                
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '尾纤' :      
                counters1['d134'] += 1               
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '整机':      
                counters1['d135'] += 1                
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '否':     #中兴存储 
                counters1['d136'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '否':      
                counters1['d137'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '网卡' and row['是否国产'] == '否':     
                counters1['d138'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == 'PCIE卡' and row['是否国产'] == '否':     
                counters1['d139'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == 'raid卡' and row['是否国产'] == '否':      
                counters1['d140'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '风扇' :      
                counters1['d141'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '是':      
                counters1['d142'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '是':      
                counters1['d143'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '光模块' :      
                counters1['d144'] += 1      
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '内存' :      
                counters1['d145'] += 1   
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '缓存盘' :     
                counters1['d146'] += 1   
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '背板' :     
                counters1['d147'] += 1      
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '传感器' :      
                counters1['d148'] += 1      
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == 'RISER卡' :      
                counters1['d149'] += 1      
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '主板' :      
                counters1['d150'] += 1         
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '电源' :      
                counters1['d151'] += 1         
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '尾纤' :      
                counters1['d152'] += 1     
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '中兴' and row['板件种类'].strip() == '整机':      
                counters1['d153'] += 1         
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '否':     #浪潮计算 
                counters1['d154'] += 1       
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '否':     
                counters1['d155'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'PCIE卡' and row['是否国产'] == '否':    
                counters1['d156'] += 1      
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and  row['板件种类'].strip() == 'cpu' and row['是否国产'] == '是':     
                counters1['d157'] += 1       
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '网卡' and row['是否国产'] == '是':     
                counters1['d158'] += 1       
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'PCIE卡' and row['是否国产'] == '是':    
                counters1['d159'] += 1          
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'raid卡' and row['是否国产'] == '是':     
                counters1['d160'] += 1          
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '风扇':     
                counters1['d161'] += 1
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '光模块' :     
                counters1['d162'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '内存' :     
                counters1['d163'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '缓存盘' :     
                counters1['d164'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '背板' :     
                counters1['d165'] += 1                                                                     
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '传感器' :     
                counters1['d166'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'RISER卡' :     
                counters1['d167'] += 1             
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '主板' :     
                counters1['d168'] += 1                
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '电源' :     
                counters1['d169'] += 1                
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '尾纤' :     
                counters1['d170'] += 1                
            elif  row['设备归属类别']=='计算' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '整机':
                counters1['d171'] += 1                
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '否':     #浪潮存储 
                counters1['d172'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'cpu' and row['是否国产'] == '否':     
                counters1['d173'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'PCIE卡' and row['是否国产'] == '否':     
                counters1['d174'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'cpu'  and row['是否国产'] == '是':     
                counters1['d175'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '网卡' and row['是否国产'] == '是':     
                counters1['d176'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'PCIE卡' and row['是否国产'] == '是':     
                counters1['d177'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'raid卡' and row['是否国产'] == '是':     
                counters1['d178'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '风扇' :     
                counters1['d179'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '光模块' :     
                counters1['d180'] += 1   
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '内存' :     
                counters1['d181'] += 1   
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '缓存盘' :     
                counters1['d182'] += 1   
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '背板' :     
                counters1['d183'] += 1      
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '传感器' :     
                counters1['d184'] += 1      
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == 'RISER卡' :     
                counters1['d185'] += 1      
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '主板' :     
                counters1['d186'] += 1         
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '电源' :     
                counters1['d187'] += 1         
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '尾纤' :     
                counters1['d188'] += 1         
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '整机':
                counters1['d189'] += 1
            elif  row['设备归属类别']=='存储' and row['设备厂家'] == '浪潮' and row['板件种类'].strip() == '硬盘' and row['是否国产'] == '是':  #新增2025年07月29日
                counters1['d190'] += 1
            # 3.1：详细故障描述##################################################
            #1期 浪潮----------------------------------------
            if (row['所属资源池'] == 'dmz' and row['所属期次'] == '1期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '浪潮'):
                panel_types3 = {
                    '硬盘': 'f70','cpu': 'f71','网卡': 'f72','PCIE卡': 'f73','raid卡': 'f74','风扇': 'f75','光模块': 'f76','内存': 'f77','缓存盘': 'f78','背板': 'f79',
                    '传感器': 'f80','RISER卡': 'f81','主板': 'f82','电源': 'f83','尾纤': 'f84', '整机': 'f85'
                              }
                
                if row['板件种类'].strip() in panel_types3:
                    counters3[panel_types3[row['板件种类'].strip()]] += 1
            
            if (row['所属资源池'] == '可信1' and row['所属期次'] == '1期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '浪潮'):
                panel_types4 = {
                    '硬盘': 'g70','cpu': 'g71','网卡': 'g72','PCIE卡': 'g73','raid卡': 'g74','风扇': 'g75','光模块': 'g76','内存': 'g77','缓存盘': 'g78','背板': 'g79',
                    '传感器': 'g80','RISER卡': 'g81','主板': 'g82','电源': 'g83','尾纤': 'g84', '整机': 'g85'
                              }
                
                if row['板件种类'].strip() in panel_types4:
                    counters4[panel_types4[row['板件种类'].strip()]] += 1

            if (row['所属资源池'] == '可信2' and row['所属期次'] == '1期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '浪潮'):
                panel_types5 = {
                    '硬盘': 'h70','cpu': 'h71','网卡': 'h72','PCIE卡': 'h73','raid卡': 'h74','风扇': 'h75','光模块': 'h76','内存': 'h77','缓存盘': 'h78','背板': 'h79',
                    '传感器': 'h80','RISER卡': 'h81','主板': 'h82','电源': 'h83','尾纤': 'h84', '整机': 'h85'
                              }
                
                if row['板件种类'].strip() in panel_types5:
                    counters5[panel_types5[row['板件种类'].strip()]] += 1
            
            #1期 华为存储------------------------------------------------------
            if (row['所属资源池'] == 'dmz' and row['所属期次'] == '1期' 
                and row['设备归属类别'] == '存储' and row['设备厂家'] == '华为'):
                panel_types6 = {
                    '硬盘': 'i70','cpu': 'i71','网卡': 'i72','PCIE卡': 'i73','raid卡': 'i74','风扇': 'i75','光模块': 'i76','内存': 'i77','缓存盘': 'i78','背板': 'i79',
                    '传感器': 'i80','RISER卡': 'i81','主板': 'i82','电源': 'i83','尾纤': 'i84', '整机': 'i85'
                              }
                
                if row['板件种类'].strip() in panel_types6:
                    counters6[panel_types6[row['板件种类'].strip()]] += 1

            if (row['所属资源池'] == '可信1' and row['所属期次'] == '1期' 
                and row['设备归属类别'] == '存储' and row['设备厂家'] == '华为'):
                panel_types7 = {
                    '硬盘': 'j70','cpu': 'j71','网卡': 'j72','PCIE卡': 'j73','raid卡': 'j74','风扇': 'j75','光模块': 'j76','内存': 'j77','缓存盘': 'j78','背板': 'j79',
                    '传感器': 'j80','RISER卡': 'j81','主板': 'j82','电源': 'j83','尾纤': 'j84', '整机': 'j85'
                              }
                
                if row['板件种类'].strip() in panel_types7:
                    counters7[panel_types7[row['板件种类'].strip()]] += 1
            #1期中兴存储------------------------------------------------------------
            if (row['所属资源池'] == '可信2' and row['所属期次'] == '1期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '中兴'):
                panel_types8 = {
                    '硬盘': 'k70', 'cpu': 'k71','网卡': 'k72', 'PCIE卡': 'k73', 'raid卡': 'k74', '风扇': 'k75', '光模块': 'k76', '内存': 'k77', '缓存盘': 'k78', '背板': 'k79',
                    '传感器': 'k80', 'RISER卡': 'k81', '主板': 'k82', '电源': 'k83', '尾纤': 'k84', '整机': 'k85'
                }
                
                if row['板件种类'].strip() in panel_types8:
                    counters8[panel_types8[row['板件种类'].strip()]] += 1
             
            # 2期  华三--------------------------------------------
            if (row['所属资源池'] == '网管6' and row['所属期次'] == '2期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '新华三'):
                panel_types2 = {
                    '硬盘': 'e70','cpu': 'e71','网卡': 'e72','PCIE卡': 'e73','raid卡': 'e74','风扇': 'e75','光模块': 'e76','内存': 'e77','缓存盘': 'e78','背板': 'e79','传感器': 'e80','RISER卡': 'e81','主板': 'e82','电源': 'e83','尾纤': 'e84',
                    '整机': 'e85' }
                
                if row['板件种类'].strip() in panel_types2:
                    counters2[panel_types2[row['板件种类'].strip()]] += 1
            #2期   超 聚变
            if (row['所属资源池'] == 'dmz' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '超聚变'):
                panel_types9 = {
                    '硬盘': 'l70','cpu': 'l71','网卡': 'l72','PCIE卡': 'l73','raid卡': 'l74','风扇': 'l75','光模块': 'l76','内存': 'l77','缓存盘': 'l78','背板': 'l79',
                    '传感器': 'l80','RISER卡': 'l81','主板': 'l82','电源': 'l83','尾纤': 'l84', '整机': 'l85'
                              }
                
                if row['板件种类'].strip() in panel_types9:
                    counters9[panel_types9[row['板件种类'].strip()]] += 1
            
            if (row['所属资源池'] == '可信1' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '超聚变'):
                panel_types10 = {
                    '硬盘': 'm70','cpu': 'm71','网卡': 'm72','PCIE卡': 'm73','raid卡': 'm74','风扇': 'm75','光模块': 'm76','内存': 'm77','缓存盘': 'm78','背板': 'm79',
                    '传感器': 'm80','RISER卡': 'm81','主板': 'm82','电源': 'm83','尾纤': 'm84', '整机': 'm85'
                              }
                
                if row['板件种类'].strip() in panel_types10:
                    counters10[panel_types10[row['板件种类'].strip()]] += 1

            if (row['所属资源池'] == '可信2' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '超聚变'):
                panel_types11 = {
                    '硬盘': 'n70','cpu': 'n71','网卡': 'n72','PCIE卡': 'n73','raid卡': 'n74','风扇': 'n75','光模块': 'n76','内存': 'n77','缓存盘': 'n78','背板': 'n79',
                    '传感器': 'n80','RISER卡': 'n81','主板': 'n82','电源': 'n83','尾纤': 'n84', '整机': 'n85'
                              }
                
                if row['板件种类'].strip() in panel_types11:
                    counters11[panel_types11[row['板件种类'].strip()]] += 1
            
            if (row['所属资源池'] == '可信3' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '超聚变'):
                panel_types12 = {
                    '硬盘': 'o70','cpu': 'o71','网卡': 'o72','PCIE卡': 'o73','raid卡': 'o74','风扇': 'o75','光模块': 'o76','内存': 'o77','缓存盘': 'o78','背板': 'o79',
                    '传感器': 'o80','RISER卡': 'o81','主板': 'o82','电源': 'o83','尾纤': 'o84', '整机': 'o85'
                              }
                
                if row['板件种类'].strip() in panel_types12:
                    counters12[panel_types12[row['板件种类'].strip()]] += 1
            
            if (row['所属资源池'] == '可信4' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '超聚变'):
                panel_types13 = {
                    '硬盘': 'p70','cpu': 'p71','网卡': 'p72','PCIE卡': 'p73','raid卡': 'p74','风扇': 'p75','光模块': 'p76','内存': 'p77','缓存盘': 'p78','背板': 'p79',
                    '传感器': 'p80','RISER卡': 'p81','主板': 'p82','电源': 'p83','尾纤': 'p84', '整机': 'p85'
                              }
                
                if row['板件种类'].strip() in panel_types13:
                    counters13[panel_types13[row['板件种类'].strip()]] += 1
            
            if (row['所属资源池'] == '可信5' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '超聚变'):
                panel_types14 = {
                    '硬盘': 'q70','cpu': 'q71','网卡': 'q72','PCIE卡': 'q73','raid卡': 'q74','风扇': 'q75','光模块': 'q76','内存': 'q77','缓存盘': 'q78','背板': 'q79',
                    '传感器': 'q80','RISER卡': 'q81','主板': 'q82','电源': 'q83','尾纤': 'q84', '整机': 'q85'
                              }
                
                if row['板件种类'].strip() in panel_types14:
                    counters14[panel_types14[row['板件种类'].strip()]] += 1
            
            if (row['所属资源池'] == '网管6' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '计算' and row['设备厂家'] == '超聚变'):
                panel_types15 = {
                    '硬盘': 'r70','cpu': 'r71','网卡': 'r72','PCIE卡': 'r73','raid卡': 'r74','风扇': 'r75','光模块': 'r76','内存': 'r77','缓存盘': 'r78','背板': 'r79',
                    '传感器': 'r80','RISER卡': 'r81','主板': 'r82','电源': 'r83','尾纤': 'r84', '整机': 'r85'
                              }
                
                if row['板件种类'].strip() in panel_types15:
                    counters15[panel_types15[row['板件种类'].strip()]] += 1
            #2期华为存储
            if (row['所属资源池'] == 'dmz' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '存储' and row['设备厂家'] == '华为'):
                panel_types16 = {
                    '硬盘': 's70','cpu': 's71','网卡': 's72','PCIE卡': 's73','raid卡': 's74','风扇': 's75','光模块': 's76','内存': 's77','缓存盘': 's78','背板': 's79',
                    '传感器': 's80','RISER卡': 's81','主板': 's82','电源': 's83','尾纤': 's84', '整机': 's85'
                              }
                
                if row['板件种类'].strip() in panel_types16:
                    counters16[panel_types16[row['板件种类'].strip()]] += 1

            if (row['所属资源池'] == '可信1' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '存储' and row['设备厂家'] == '华为'):
                panel_types17 = {
                    '硬盘': 't70','cpu': 't71','网卡': 't72','PCIE卡': 't73','raid卡': 't74','风扇': 't75','光模块': 't76','内存': 't77','缓存盘': 't78','背板': 't79',
                    '传感器': 't80','RISER卡': 't81','主板': 't82','电源': 't83','尾纤': 't84', '整机': 't85'
                              }
                
                if row['板件种类'].strip() in panel_types17:
                    counters17[panel_types17[row['板件种类'].strip()]] += 1
            
            if (row['所属资源池'] == '可信3' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '存储' and row['设备厂家'] == '华为'):
                panel_types18 = {
                    '硬盘': 'u70','cpu': 'u71','网卡': 'u72','PCIE卡': 'u73','raid卡': 'u74','风扇': 'u75','光模块': 'u76','内存': 'u77','缓存盘': 'u78','背板': 'u79',
                    '传感器': 'u80','RISER卡': 'u81','主板': 'u82','电源': 'u83','尾纤': 'u84', '整机': 'u85'
                              }
                
                if row['板件种类'].strip() in panel_types18:
                    counters18[panel_types18[row['板件种类'].strip()]] += 1

            if (row['所属资源池'] == '可信4' and row['所属期次'] == '2期' 
                and row['设备归属类别'] == '存储' and row['设备厂家'] == '华为'):
                panel_types19 = {
                    '硬盘': 'v70','cpu': 'v71','网卡': 'v72','PCIE卡': 'v73','raid卡': 'v74','风扇': 'v75','光模块': 'v76','内存': 'v77','缓存盘': 'v78','背板': 'v79',
                    '传感器': 'v80','RISER卡': 'v81','主板': 'v82','电源': 'v83','尾纤': 'v84', '整机': 'v85'
                              }
                
                if row['板件种类'].strip() in panel_types19:
                    counters19[panel_types19[row['板件种类'].strip()]] += 1
            #2期中兴存储
            if (row['所属资源池'] == '可信2' and row['所属期次'] == '2期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '中兴'):
                panel_types20 = {
                    '硬盘': 'w70','cpu': 'w71','网卡': 'w72','PCIE卡': 'w73','raid卡': 'w74','风扇': 'w75','光模块': 'w76','内存': 'w77','缓存盘': 'w78','背板': 'w79',
                    '传感器': 'w80','RISER卡': 'w81','主板': 'w82','电源': 'w83','尾纤': 'w84', '整机': 'w85'
                }
                
                if row['板件种类'].strip() in panel_types20:
                    counters20[panel_types20[row['板件种类'].strip()]] += 1
            #2期浪潮存储
            if (row['所属资源池'] == '可信5' and row['所属期次'] == '2期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '浪潮'):
                panel_types21 = {
                    '硬盘': 'x70','cpu': 'x71','网卡': 'x72','PCIE卡': 'x73','raid卡': 'x74','风扇': 'x75','光模块': 'x76','内存': 'x77','缓存盘': 'x78','背板': 'x79',
                    '传感器': 'x80','RISER卡': 'x81','主板': 'x82','电源': 'x83','尾纤': 'x84', '整机': 'x85'
                }
            
                if row['板件种类'].strip() in panel_types21:
                    counters21[panel_types21[row['板件种类'].strip()]] += 1
            #3期    中兴计算++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            if (row['所属资源池'] == 'dmz' and row['所属期次'] == '3期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '中兴'):
                panel_types22 = {
                    '硬盘': 'ee70','cpu': 'ee71','网卡': 'ee72','PCIE卡': 'ee73','raid卡': 'ee74','风扇': 'ee75','光模块': 'ee76','内存': 'ee77','缓存盘': 'ee78','背板': 'ee79',
                    '传感器': 'ee80','RISER卡': 'ee81','主板': 'ee82','电源': 'ee83','尾纤': 'ee84', '整机': 'ee85'
                }
            
                if row['板件种类'].strip() in panel_types22:
                    counters22[panel_types22[row['板件种类'].strip()]] += 1
            if (row['所属资源池'] == '可信2' and row['所属期次'] == '3期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '中兴'):
                panel_types23 = {
                    '硬盘': 'ff70','cpu': 'ff71','网卡': 'ff72','PCIE卡': 'ff73','raid卡': 'ff74','风扇': 'ff75','光模块': 'ff76','内存': 'ff77','缓存盘': 'ff78','背板': 'ff79',
                    '传感器': 'ff80','RISER卡': 'ff81','主板': 'ff82','电源': 'ff83','尾纤': 'ff84', '整机': 'ff85'
                }
            
                if row['板件种类'].strip() in panel_types23:
                    counters23[panel_types23[row['板件种类'].strip()]] += 1
            if (row['所属资源池'] == '可信4' and row['所属期次'] == '3期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '中兴'):
                panel_types24 = {
                    '硬盘': 'gg70','cpu': 'gg71','网卡': 'gg72','PCIE卡': 'gg73','raid卡': 'gg74','风扇': 'gg75','光模块': 'gg76','内存': 'gg77','缓存盘': 'gg78','背板': 'gg79',
                    '传感器': 'gg80','RISER卡': 'gg81','主板': 'gg82','电源': 'gg83','尾纤': 'gg84', '整机': 'gg85'
                }
            
                if row['板件种类'].strip() in panel_types24:
                    counters24[panel_types24[row['板件种类'].strip()]] += 1
            if (row['所属资源池'] == '可信5' and row['所属期次'] == '3期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '中兴'):
                panel_types25 = {
                    '硬盘': 'hh70','cpu': 'hh71','网卡': 'hh72','PCIE卡': 'hh73','raid卡': 'hh74','风扇': 'hh75','光模块': 'hh76','内存': 'hh77','缓存盘': 'hh78','背板': 'hh79',
                    '传感器': 'hh80','RISER卡': 'hh81','主板': 'hh82','电源': 'hh83','尾纤': 'hh84', '整机': 'hh85'
                }
            
                if row['板件种类'].strip() in panel_types25:
                    counters25[panel_types25[row['板件种类'].strip()]] += 1
            if (row['所属资源池'] == '网管6' and row['所属期次'] == '3期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '中兴'):
                panel_types26 = {
                    '硬盘': 'ii70','cpu': 'ii71','网卡': 'ii72','PCIE卡': 'ii73','raid卡': 'ii74','风扇': 'ii75','光模块': 'ii76','内存': 'ii77','缓存盘': 'ii78','背板': 'ii79',
                    '传感器': 'ii80','RISER卡': 'ii81','主板': 'ii82','电源': 'ii83','尾纤': 'ii84', '整机': 'ii85'
                }
            
                if row['板件种类'].strip() in panel_types26:
                    counters26[panel_types26[row['板件种类'].strip()]] += 1
            #中兴存储
            if (row['所属资源池'] == '可信2' and row['所属期次'] == '3期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '中兴'):
                panel_types27 = {
                    '硬盘': 'jj70','cpu': 'jj71','网卡': 'jj72','PCIE卡': 'jj73','raid卡': 'jj74','风扇': 'jj75','光模块': 'jj76','内存': 'jj77','缓存盘': 'jj78','背板': 'jj79',
                    '传感器': 'jj80','RISER卡': 'jj81','主板': 'jj82','电源': 'jj83','尾纤': 'jj84', '整机': 'jj85'
                }
            
                if row['板件种类'].strip() in panel_types27:
                    counters27[panel_types27[row['板件种类'].strip()]] += 1
            if (row['所属资源池'] == '可信7' and row['所属期次'] == '3期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '中兴'):
                panel_types28 = {
                    '硬盘': 'kk70','cpu': 'kk71','网卡': 'kk72','PCIE卡': 'kk73','raid卡': 'kk74','风扇': 'kk75','光模块': 'kk76','内存': 'kk77','缓存盘': 'kk78','背板': 'kk79',
                    '传感器': 'kk80','RISER卡': 'kk81','主板': 'kk82','电源': 'kk83','尾纤': 'kk84', '整机': 'kk85'
                }
            
                if row['板件种类'].strip() in panel_types28:
                    counters28[panel_types28[row['板件种类'].strip()]] += 1
            #新华三存储
            if (row['所属资源池'] == '网管6' and row['所属期次'] == '3期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '新华三'):
                panel_types29 = {
                    '硬盘': 'll70','cpu': 'll71','网卡': 'll72','PCIE卡': 'll73','raid卡': 'll74','风扇': 'll75','光模块': 'll76','内存': 'll77','缓存盘': 'll78','背板': 'll79',
                    '传感器': 'll80','RISER卡': 'll81','主板': 'll82','电源': 'll83','尾纤': 'll84', '整机': 'll85'
                }
            
                if row['板件种类'].strip() in panel_types29:
                    counters29[panel_types29[row['板件种类'].strip()]] += 1
            #浪潮计算
            if (row['所属资源池'] == '网管6' and row['所属期次'] == '3期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '浪潮'):
                panel_types30 = {
                    '硬盘': 'mm70','cpu': 'mm71','网卡': 'mm72','PCIE卡': 'mm73','raid卡': 'mm74','风扇': 'mm75','光模块': 'mm76','内存': 'mm77','缓存盘': 'mm78','背板': 'mm79',
                    '传感器': 'mm80','RISER卡': 'mm81','主板': 'mm82','电源': 'mm83','尾纤': 'mm84', '整机': 'mm85'
                }
            
                if row['板件种类'].strip() in panel_types30:
                    counters30[panel_types30[row['板件种类'].strip()]] += 1
            if (row['所属资源池'] == '可信7' and row['所属期次'] == '3期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '浪潮'):
                panel_types31 = {
                    '硬盘': 'nn70','cpu': 'nn71','网卡': 'nn72','PCIE卡': 'nn73','raid卡': 'nn74','风扇': 'nn75','光模块': 'nn76','内存': 'nn77','缓存盘': 'nn78','背板': 'nn79',
                    '传感器': 'nn80','RISER卡': 'nn81','主板': 'nn82','电源': 'nn83','尾纤': 'nn84', '整机': 'nn85'
                }
            
                if row['板件种类'].strip() in panel_types31:
                    counters31[panel_types31[row['板件种类'].strip()]] += 1
            #浪潮存储
            if (row['所属资源池'] == '可信5' and row['所属期次'] == '3期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '浪潮'):
                panel_types32 = {
                    '硬盘': 'oo70','cpu': 'oo71','网卡': 'oo72','PCIE卡': 'oo73','raid卡': 'oo74','风扇': 'oo75','光模块': 'oo76','内存': 'oo77','缓存盘': 'oo78','背板': 'oo79',
                    '传感器': 'oo80','RISER卡': 'oo81','主板': 'oo82','电源': 'oo83','尾纤': 'oo84', '整机': 'oo85'
                }
            
                if row['板件种类'].strip() in panel_types32:
                    counters32[panel_types32[row['板件种类'].strip()]] += 1
            #4期中兴计算++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            if (row['所属资源池'] == '网管6' and row['所属期次'] == '4期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '中兴'):
                panel_types33 = {
                    '硬盘': 'pp70','cpu': 'pp71','网卡': 'pp72','PCIE卡': 'pp73','raid卡': 'pp74','风扇': 'pp75','光模块': 'pp76','内存': 'pp77','缓存盘': 'pp78','背板': 'pp79',
                    '传感器': 'pp80','RISER卡': 'pp81','主板': 'pp82','电源': 'pp83','尾纤': 'pp84', '整机': 'pp85'
                }
            
                if row['板件种类'].strip() in panel_types33:
                    counters33[panel_types33[row['板件种类'].strip()]] += 1
            if (row['所属资源池'] == '可信8' and row['所属期次'] == '4期' and row['设备归属类别'] == '计算' and row['设备厂家'] == '中兴'):
                panel_types34 = {
                    '硬盘': 'qq70','cpu': 'qq71','网卡': 'qq72','PCIE卡': 'qq73','raid卡': 'qq74','风扇': 'qq75','光模块': 'qq76','内存': 'qq77','缓存盘': 'qq78','背板': 'qq79',
                    '传感器': 'qq80','RISER卡': 'qq81','主板': 'qq82','电源': 'qq83','尾纤': 'qq84', '整机': 'qq85'
                }
            
                if row['板件种类'].strip() in panel_types34:
                    counters34[panel_types34[row['板件种类'].strip()]] += 1
            #浪潮存储
            if (row['所属资源池'] == '可信8' and row['所属期次'] == '4期' and row['设备归属类别'] == '存储' and row['设备厂家'] == '浪潮'):
                panel_types35 = {
                    '硬盘': 'rr70','cpu': 'rr71','网卡': 'rr72','PCIE卡': 'rr73','raid卡': 'rr74','风扇': 'rr75','光模块': 'rr76','内存': 'rr77','缓存盘': 'rr78','背板': 'rr79',
                    '传感器': 'rr80','RISER卡': 'rr81','主板': 'rr82','电源': 'rr83','尾纤': 'rr84', '整机': 'rr85'
                }
            
                if row['板件种类'].strip() in panel_types35:
                    counters35[panel_types35[row['板件种类'].strip()]] += 1
        
        #1.1.1:故障数量分期统计       
        counters['the_first_phase'] = sum([counters['d52'], counters['d53'], counters['d54']])
        counters['the_second_phase'] = sum([counters['d55'], counters['d56'], counters['d57'], counters['d58'], counters['d59'], counters['d60'], counters['d61']])
        counters['the_third_phase'] = sum([counters['d62'], counters['d63'], counters['d64'], counters['d65'], counters['d66'], counters['d67']])
        counters['the_fourth_phase'] = sum([counters['d68'], counters['d69']])
        #1.1.2:打印故障数量分期统计，用于调测
        print(f"一、\n1期dmz、可信1、可信2的计数以及总和分别为：\n{counters['d52']}, {counters['d53']}, {counters['d54']}： {counters['the_first_phase']}")
        print(f"2期dmz、可信1、可信2、可信3、可信4、可信5、网管6的计数以及总和分别为：\n{counters['d55']}, {counters['d56']}, {counters['d57']}, {counters['d58']}, {counters['d59']}, {counters['d60']}, {counters['d61']}： {counters['the_second_phase']}")
        print(f"3期dmz、可信2、可信4、可信5、网管6、可信7的计数以及总和分别为：\n{counters['d62']}, {counters['d63']}, {counters['d64']}, {counters['d65']},{counters['d66']}, {counters['d67']}： {counters['the_third_phase']}")
        print(f"4期可信8、网管6的计数以及总和分别为：\n{counters['d68']}, {counters['d69']}： {counters['the_fourth_phase']}")

        #2.1
        counters1['h3c_storage'] = sum([counters1['d70'], counters1['d71'], counters1['d72'],counters1['d73'], counters1['d74'], counters1['d75'],counters1['d76'], counters1['d77'], counters1['d78'],counters1['d79'], counters1['d80'], counters1['d81'],counters1['d82'], counters1['d83'],counters1['d84'], counters1['d85']])
        counters1['xfusion_computer'] = sum([counters1['d86'], counters1['d87'], counters1['d88'],counters1['d89'], counters1['d90'], counters1['d91'],counters1['d92'], counters1['d93'], counters1['d94'],counters1['d95'], counters1['d96'], counters1['d97'],counters1['d98'], counters1['d99'],counters1['d100'], counters1['d101']])
        counters1['huawei_storage'] = sum([counters1['d102'], counters1['d103'], counters1['d104'],counters1['d105'], counters1['d106'], counters1['d107'],counters1['d108'], counters1['d109'], counters1['d110'],counters1['d111'], counters1['d112'], counters1['d113'],counters1['d114'], counters1['d115'],counters1['d116'], counters1['d117']])
        counters1['zte_computer'] = sum([counters1['d118'], counters1['d119'], counters1['d120'],counters1['d121'], counters1['d122'], counters1['d123'],counters1['d124'], counters1['d125'], counters1['d126'],counters1['d127'], counters1['d128'], counters1['d129'],counters1['d130'], counters1['d131'],counters1['d132'], counters1['d133'],counters1['d134'], counters1['d135']])
        counters1['zte_storage'] = sum([counters1['d136'], counters1['d137'], counters1['d138'],counters1['d139'], counters1['d140'], counters1['d141'],counters1['d142'], counters1['d143'], counters1['d144'],counters1['d145'], counters1['d146'], counters1['d147'],counters1['d148'], counters1['d149'],counters1['d150'], counters1['d151'],counters1['d152'], counters1['d153']])
        counters1['inspur_computer'] = sum([counters1['d154'], counters1['d155'], counters1['d156'],counters1['d157'], counters1['d158'], counters1['d159'],counters1['d160'], counters1['d161'], counters1['d162'],counters1['d163'], counters1['d164'], counters1['d165'],counters1['d166'], counters1['d167'],counters1['d168'], counters1['d169'],counters1['d170'], counters1['d171']])
        counters1['inspur_storage'] = sum([counters1['d172'], counters1['d173'], counters1['d174'],counters1['d175'], counters1['d176'], counters1['d177'],counters1['d178'], counters1['d179'], counters1['d180'],counters1['d181'], counters1['d182'], counters1['d183'],counters1['d184'], counters1['d185'],counters1['d186'], counters1['d187'],counters1['d188'], counters1['d189'],counters1['d190']])
        
        #3.1
        #2期新华三故障部件总数
        counters2['sum2_h3'] = sum(counters2.get(f'e{i}', 0) for i in range(70, 86))
        print(f"二、\n2期网管6新华三存储故障部件总数: {counters2['sum2_h3']}")
        #2期超聚变
        counters9['sum2_xfusion_computer_dmz'] = sum(counters9[f'l{i}'] for i in range(70, 86))
        print(f"2期dmz超聚变计算故障部件总数: {counters9['sum2_xfusion_computer_dmz']}")    
        counters10['sum2_xfusion_computer_trust1'] = sum(counters10.get(f'm{i}', 0) for i in range(70, 86))
        print(f"2期可信1超聚变计算故障部件总数: {counters10['sum2_xfusion_computer_trust1']}")
        counters11['sum2_xfusion_computer_trust2'] = sum(counters11.get(f'n{i}', 0) for i in range(70, 86))
        print(f"2期可信2超聚变计算故障部件总数: {counters11['sum2_xfusion_computer_trust2']}")
        counters12['sum2_xfusion_computer_trust3'] = sum(counters12.get(f'o{i}', 0) for i in range(70, 86))
        print(f"2期可信3超聚变计算故障部件总数: {counters12['sum2_xfusion_computer_trust3']}")
        counters13['sum2_xfusion_computer_trust4'] = sum(counters13.get(f'p{i}', 0) for i in range(70, 86))
        print(f"2期可信4超聚变计算故障部件总数: {counters13['sum2_xfusion_computer_trust4']}")
        counters14['sum2_xfusion_computer_trust5'] = sum(counters14.get(f'q{i}', 0) for i in range(70, 86))
        print(f"2期可信5超聚变计算故障部件总数: {counters14['sum2_xfusion_computer_trust5']}")
        counters15['sum2_xfusion_computer_wg6'] = sum(counters15.get(f'r{i}', 0) for i in range(70, 86))
        print(f"2期网管6超聚变计算故障部件总数: {counters15['sum2_xfusion_computer_wg6']}")
        #2期华为存储
        counters16['sum2_huawei_storage_dmz'] = sum(counters16.get(f's{i}', 0) for i in range(70, 86))
        print(f"2期dmz华为存储故障部件总数: {counters16['sum2_huawei_storage_dmz']}")
        counters17['sum2_huawei_storage_trust1'] = sum(counters17.get(f't{i}', 0) for i in range(70, 86))
        print(f"2期可信1华为存储故障部件总数: {counters17['sum2_huawei_storage_trust1']}")
        counters18['sum2_huawei_storage_trust3'] = sum(counters18.get(f'u{i}', 0) for i in range(70, 86))
        print(f"2期可信3华为存储故障部件总数: {counters18['sum2_huawei_storage_trust3']}")
        counters19['sum2_huawei_storage_trust4'] = sum(counters19.get(f'v{i}', 0) for i in range(70, 86))
        print(f"2期可信4华为存储故障部件总数: {counters19['sum2_huawei_storage_trust4']}")
        #2期中兴存储
        counters20['sum2_zte_storage_trust2'] = sum(counters20.get(f'w{i}', 0) for i in range(70, 86))
        print(f"2期可信2中兴存储故障部件总数: {counters20['sum2_zte_storage_trust2']}")
        #2期浪潮存储
        counters21['sum2_inspur_storage_trust5'] = sum(counters21.get(f'x{i}', 0) for i in range(70, 86))
        print(f"2期可信5浪潮存储故障部件总数: {counters21['sum2_inspur_storage_trust5']}")       
        #1期浪潮
        counters3['sum_inspur_computer_dmz'] = sum(counters3.get(f'f{i}', 0) for i in range(70, 86))
        print(f"1期dmz资源池浪潮计算故障部件总数: {counters3['sum_inspur_computer_dmz']}")        
        counters4['sum_inspur_computer_trust1'] = sum(counters4.get(f'g{i}', 0) for i in range(70, 86))
        print(f"1期可信1资源池浪潮计算故障部件总数: {counters4['sum_inspur_computer_trust1']}")       
        counters5['sum_inspur_computer_trust2'] = sum(counters5.get(f'h{i}', 0) for i in range(70, 86))
        print(f"1期可信2资源池浪潮计算故障部件总数: {counters5['sum_inspur_computer_trust2']}")        
        #1期华为存储
        counters6['sum_huawei_storage_dmz'] = sum(counters6.get(f'i{i}', 0) for i in range(70, 86))
        print(f"1期dmz资源池华为存储故障部件总数: {counters6['sum_huawei_storage_dmz']}")        
        counters7['sum_huawei_storage_trust1'] = sum(counters7.get(f'j{i}', 0) for i in range(70, 86))
        print(f"1期可信1资源池华为存储故障部件总数: {counters7['sum_huawei_storage_trust1']}")       
        #1期中兴存储
        counters8['sum_zte_storage_trust2'] = sum(counters8.get(f'k{i}', 0) for i in range(70, 86))
        print(f"1期可信2资源池中兴存储故障部件总数: {counters8['sum_zte_storage_trust2']}")
        #3期中兴计算
        counters22['sum3_zte_computer_dmz'] = sum(counters22.get(f'ee{i}', 0) for i in range(70, 86))
        print(f"3期dmz中兴计算故障部件总数: {counters22['sum3_zte_computer_dmz']}")
        counters23['sum3_zte_computer_trust2'] = sum(counters23.get(f'ff{i}', 0) for i in range(70, 86))
        print(f"3期可信2中兴计算故障部件总数: {counters23['sum3_zte_computer_trust2']}")
        counters24['sum3_zte_computer_trust4'] = sum(counters24.get(f'gg{i}', 0) for i in range(70, 86))
        print(f"3期可信4中兴计算故障部件总数: {counters24['sum3_zte_computer_trust4']}")
        counters25['sum3_zte_computer_trust5'] = sum(counters25.get(f'hh{i}', 0) for i in range(70, 86))
        print(f"3期可信5中兴计算故障部件总数: {counters25['sum3_zte_computer_trust5']}")
        counters26['sum3_zte_computer_wg6'] = sum(counters26.get(f'ii{i}', 0) for i in range(70, 86))
        print(f"3期网管6中兴计算故障部件总数: {counters26['sum3_zte_computer_wg6']}")
        #3期中兴存储
        counters27['sum3_zte_storage_trust2'] = sum(counters27.get(f'jj{i}', 0) for i in range(70, 86))
        print(f"3期可信2中兴存储故障部件总数: {counters27['sum3_zte_storage_trust2']}")
        counters28['sum3_zte_storage_trust7'] = sum(counters28.get(f'kk{i}', 0) for i in range(70, 86))
        print(f"3期可信7中兴存储故障部件总数: {counters28['sum3_zte_storage_trust7']}")
        #3期新华三存储
        counters29['sum3_h3c_storage_wg6'] = sum(counters29.get(f'll{i}', 0) for i in range(70, 86))
        print(f"3期网管6新华三存储故障部件总数: {counters29['sum3_h3c_storage_wg6']}")
        #3期浪潮计算
        counters30['sum3_inspur_computer_wg6'] = sum(counters30.get(f'mm{i}', 0) for i in range(70, 86))
        print(f"3期网管6浪潮计算故障部件总数: {counters30['sum3_inspur_computer_wg6']}")
        counters31['sum3_inspur_computer_trust7'] = sum(counters31.get(f'nn{i}', 0) for i in range(70, 86))
        print(f"3期可信7浪潮计算故障部件总数: {counters31['sum3_inspur_computer_trust7']}")
        #3期浪潮存储
        counters32['sum3_inspur_storage_trust5'] = sum(counters32.get(f'oo{i}', 0) for i in range(70, 86))
        print(f"3期可信5浪潮存储故障部件总数: {counters32['sum3_inspur_storage_trust5']}\n")
        #4期中兴计算
        counters33['sum4_zte_computer_wg6'] = sum(counters33.get(f'pp{i}', 0) for i in range(70, 86))
        print(f"4期网管6中兴计算故障部件总数: {counters33['sum4_zte_computer_wg6']}")
        counters34['sum4_zte_computer_trust8'] = sum(counters34.get(f'qq{i}', 0) for i in range(70, 86))
        print(f"4期可信8中兴计算故障部件总数: {counters34['sum4_zte_computer_trust8']}")
        #4期浪潮存储
        # 计算4期可信8资源池浪潮存储故障部件总数:
        # 1. 遍历计数器keys从'rr70'到'rr85'(range(70,86)生成70-85的数字)
        # 2. 使用counters35.get()方法获取每个key对应的值，如果key不存在则返回默认值0
        # 3. 使用sum()函数将所有部件故障数量求和
        # 4. 将求和结果存入counters35字典的'sum4_inspur_storage_trust8'键中
        counters35['sum4_inspur_storage_trust8'] = sum(counters35.get(f'rr{i}', 0) for i in range(70, 86))
        print(f"4期可信8浪潮存储故障部件总数: {counters35['sum4_inspur_storage_trust8']}\n")

        # 新文件路径（使用原始文件路径）
        new_file = file_path

        # 在原文件中进行数据增删改
        # 加载原文件
        workbook = load_workbook(file_path)
        sheet = workbook.active  # 获取活动工作表

            
        # 1.1：建立Excel单元格映射关系
        counter_mapping = {
            'd52': (71, 'D'),  # d52对应第68行D列
            'd53': (72, 'D'),
            'd54': (73, 'D'),
            'd55': (74, 'D'),
            'd56': (75, 'D'),
            'd57': (76, 'D'),
            'd58': (77, 'D'),
            'd59': (78, 'D'),
            'd60': (79, 'D'),
            'd61': (80, 'D'),
            'd62': (81, 'D'),
            'd63': (82, 'D'),
            'd64': (83, 'D'),
            'd65': (84, 'D'),
            'd66': (85, 'D'),
            'd67': (86, 'D'),
            'd68': (87, 'D'),
            'd69': (88, 'D')
            }
            
        # 遍历计数器写入单元格
        for key in counter_mapping:
            row, col = counter_mapping[key]
            cell = f"{col}{row}"
            sheet[cell] = counters[key]

        # 1.2建立Excel单元格映射关系
        counter_mapping1 = {
            'd70': (102, 'H'),#华三,d70对应第102行H列
            'd71': (102, 'D'),
            'd72': (102, 'L'),
            'd73': (102, 'P'),
            'd74': (102, 'T'),
            'd75': (102, 'W'),
            'd76': (102, 'C'),
            'd77': (102, 'G'),
            'd78': (102, 'J'),
            'd79': (102, 'K'),
            'd80': (102, 'N'),
            'd81': (102, 'O'),
            'd82': (102, 'R'),
            'd83': (102, 'S'),
            'd84': (102, 'V'),
            'd85': (102, 'Y'),
            'h3c_storage': (102, 'Z'),#华三合计

            'd86': (103, 'H'),# 超聚变,d86对应第103行H列
            'd87': (103, 'D'),
            'd88': (103, 'L'),
            'd89': (103, 'P'),
            'd90': (103, 'X'),
            'd91': (103, 'Q'),
            'd92': (103, 'C'),
            'd93': (103, 'G'),
            'd94': (103, 'J'),
            'd95': (103, 'K'),
            'd96': (103, 'N'),
            'd97': (103, 'O'),
            'd98': (103, 'R'),
            'd99': (103, 'S'),
            'd100': (103, 'V'),
            'd101': (103, 'Y'),
            'xfusion_computer': (103, 'Z'),#超聚变合计

			'd102': (95, 'H'),  # 华为存储,D102对应第95行H列
            'd103': (95, 'F'),
            'd104': (95, 'M'),
            'd105': (95, 'Q'),
            'd106': (95, 'U'),
            'd107': (95, 'X'),
            'd108': (95, 'C'),
            'd109': (95, 'G'),
            'd110': (95, 'J'),
            'd111': (95, 'K'),
            'd112': (95, 'N'),
            'd113': (95, 'O'),
            'd114': (95, 'R'),
            'd115': (95, 'S'),
            'd116': (95, 'V'),
            'd117': (95, 'Y'),
            'huawei_storage': (95, 'Z'),#华为存储合计

            'd118': (96, 'H'),  #中兴计算,D118对应第96行H列
            'd119': (96, 'D'),  #cpu
            'd120': (96, 'L'),
            'd121': (96, 'P'),
            'd122': (96, 'T'),
            'd123': (96, 'I'),
            'd124': (96, 'E'),
            'd125': (96, 'X'),
            'd126': (96, 'C'),
            'd127': (96, 'G'),
            'd128': (96, 'J'),
            'd129': (96, 'K'),
            'd130': (96, 'N'),
            'd131': (96, 'O'),
            'd132': (96, 'R'),
            'd133': (96, 'S'),
            'd134': (96, 'V'),
            'd135': (96, 'Y'),
            'zte_computer': (96, 'Z'),#中兴计算合计

            'd136': (98, 'H'),  #中兴存储,D136对应第98行H列
            'd137': (98, 'D'),
            'd138': (98, 'L'),
            'd139': (98, 'P'),
            'd140': (98, 'T'),
            'd141': (98, 'I'),
            'd142': (98, 'E'),
            'd143': (98, 'X'),
            'd144': (98, 'C'),
            'd145': (98, 'G'),
            'd146': (98, 'J'),
            'd147': (98, 'K'),
            'd148': (98, 'M'),
            'd149': (98, 'O'),
            'd150': (98, 'R'),
            'd151': (98, 'S'),
            'd152': (98, 'V'),
            'd153': (98, 'Y'),
            'zte_storage': (98, 'Z'),#中兴存储合计

            'd154':(104, 'H'),#浪潮计算，D154对应第104行H列
            'd155':(104, 'D'),
            'd156':(104, 'P'),
            'd157':(104, 'F'),
            'd158':(104, 'M'),
            'd159':(104, 'Q'),
            'd160':(104, 'U'),
            'd161':(104, 'X'),
            'd162':(104, 'C'),
            'd163':(104, 'G'),
            'd164':(104, 'J'),
            'd165':(104, 'K'),
            'd166':(104, 'N'),
            'd167':(104, 'O'),
            'd168':(104, 'R'),
            'd169':(104, 'S'),
            'd170':(104, 'V'),
            'd171':(104, 'Y'),
            'inspur_computer':(104, 'Z'),#浪潮计算合计

            'd172':(105, 'H'), #浪潮存储，D172对应第105行H列
            'd173':(105, 'D'),        
            'd174':(105, 'P'), 
            'd175':(105, 'F'), 
            'd176':(105, 'M'), 
            'd177':(105, 'Q'), 
            'd178':(105, 'U'), 
            'd179':(105, 'X'),  
            'd180':(105, 'C'),        
            'd181':(105, 'G'), 
            'd182':(105, 'J'), 
            'd183':(105, 'K'), 
            'd184':(105, 'N'), 
            'd185':(105, 'O'), 
            'd186':(105, 'R'), 
            'd187':(105, 'S'), 
            'd188':(105, 'V'), 
            'd189':(105, 'Y'),
            'd190':(105, 'I'),
            'inspur_storage':(105, 'Z')#浪潮存储合计
                        }
            
            # 遍历计数器写入单元格
        for key in counter_mapping1:
            row, col = counter_mapping1[key]  # 获取单元格的行列坐标
            cell = f"{col}{row}"  # 组合成单元格地址，如"D52"
                
                # 判断逻辑：
                # 1. 如果是合计列（中兴存储/计算或浪潮存储/计算），无论是否为0都写入
                # 2. 非合计列且值为0时，跳过不写入
                # 3. 其他情况正常写入
            if (key.endswith('storage') or key.endswith('computer')) or counters1[key] != 0:
                sheet[cell] = counters1[key] if col != 'Y' or (counters1[key] != 0 and counters1[key] is not None) else 0  # Y列数值为0或空时强制写0


        # # 3.1生成最终的文本------------------------------------------------------------------------
        #一期浪潮计算dmz
        if counters3['sum_inspur_computer_dmz'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'f70'), ('cpu', 'f71'),('网卡', 'f72'), ('PCIE卡', 'f73'),
                ('raid卡', 'f74'), ('风扇', 'f75'), ('光模块', 'f76'), ('内存', 'f77'),
                ('缓存盘', 'f78'), ('背板', 'f79'), ('传感器', 'f80'), ('RISER卡', 'f81'),
                ('主板', 'f82'), ('电源', 'f83'), ('尾纤', 'f84'), ('整机', 'f85')
            ]
            
            # Generate base text
            f_inspur_computer_dmz_text = f"dmz资源池{counters3['sum_inspur_computer_dmz']}台浪潮计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters3[key] > 0:
                    component_texts.append(f"{counters3[key]}个{name}, ")
            
            full_text_f_inspur_computer_dmz_text = f_inspur_computer_dmz_text + ''.join(component_texts)
        else:                   
            full_text_f_inspur_computer_dmz_text = ''
        #一期浪潮计算可信1-------------------------
        if counters4['sum_inspur_computer_trust1'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'g70'), ('cpu', 'g71'), ('网卡', 'g72'), ('PCIE卡', 'g73'),
                ('raid卡', 'g74'), ('风扇', 'g75'), ('光模块', 'g76'), ('内存', 'g77'),
                ('缓存盘', 'g78'), ('背板', 'g79'), ('传感器', 'g80'), ('RISER卡', 'g81'),
                ('主板', 'g82'), ('电源', 'g83'), ('尾纤', 'g84'), ('整机', 'g85')
            ]
            
            # Generate base text
            g_inspur_computer_trust1_text = f"可信1资源池{counters4['sum_inspur_computer_trust1']}台浪潮计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters4[key] > 0:
                    component_texts.append(f"{counters4[key]}个{name}, ")
            
            full_text_g_inspur_computer_trust1_text = g_inspur_computer_trust1_text + ''.join(component_texts)
        else:                   
            full_text_g_inspur_computer_trust1_text = ''
        #一期浪潮计算可信2-------------------------
        if counters5['sum_inspur_computer_trust2'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'h70'), ('cpu', 'h71'), ('网卡', 'h72'), ('PCIE卡', 'h73'),
                ('raid卡', 'h74'), ('风扇', 'h75'), ('光模块', 'h76'), ('内存', 'h77'),
                ('缓存盘', 'h78'), ('背板', 'h79'), ('传感器', 'h80'), ('RISER卡', 'h81'),
                ('主板', 'h82'), ('电源', 'h83'), ('尾纤', 'h84'), ('整机', 'h85')
            ]
            
            # Generate base text
            h_inspur_computer_trust2_text = f"可信2资源池{counters5['sum_inspur_computer_trust2']}台浪潮计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters5[key] > 0:
                    component_texts.append(f"{counters5[key]}个{name}, ")
            
            full_text_h_inspur_computer_trust2_text = h_inspur_computer_trust2_text + ''.join(component_texts)
        else:                   
            full_text_h_inspur_computer_trust2_text = ''
        #一期华为存储dmz-------------------------
        if counters6['sum_huawei_storage_dmz'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'i70'), ('cpu', 'i71'), ('网卡', 'i72'), ('PCIE卡', 'i73'),
                ('raid卡', 'i74'), ('风扇', 'i75'), ('光模块', 'i76'), ('内存', 'i77'),
                ('缓存盘', 'i78'), ('背板', 'i79'), ('传感器', 'i80'), ('RISER卡', 'i81'),
                ('主板', 'i82'), ('电源', 'i83'), ('尾纤', 'i84'), ('整机', 'i85')
            ]
            
            # Generate base text
            i_huawei_storage_dmz_text = f"dmz资源池{counters6['sum_huawei_storage_dmz']}台华为存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters6[key] > 0:
                    component_texts.append(f"{counters6[key]}个{name}, ")
            
            full_text_i_huawei_storage_dmz_text = i_huawei_storage_dmz_text + ''.join(component_texts)            
        else:            
            full_text_i_huawei_storage_dmz_text = ''
        #一期华为存储可信1-------------------------
        if counters7['sum_huawei_storage_trust1'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'j70'), ('cpu', 'j71'), ('网卡', 'j72'), ('PCIE卡', 'j73'),
                ('raid卡', 'j74'), ('风扇', 'j75'), ('光模块', 'j76'), ('内存', 'j77'),
                ('缓存盘', 'j78'), ('背板', 'j79'), ('传感器', 'j80'), ('RISER卡', 'j81'),
                ('主板', 'j82'), ('电源', 'j83'), ('尾纤', 'j84'), ('整机', 'j85')
            ]
            
            # Generate base text
            j_huawei_storage_trust1_text = f"可信1资源池{counters7['sum_huawei_storage_trust1']}台华为存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters7[key] > 0:
                    component_texts.append(f"{counters7[key]}个{name}, ")
            
            full_text_j_huawei_storage_trust1_text = j_huawei_storage_trust1_text + ''.join(component_texts)
        else:            
            full_text_j_huawei_storage_trust1_text = ''
        #一期中兴存储可信2-------------------------
        if counters8['sum_zte_storage_trust2'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'k70'), ('cpu', 'k71'),('网卡', 'k72'), ('PCIE卡', 'k73'),
                ('raid卡', 'k74'), ('风扇', 'k75'), ('光模块', 'k76'), ('内存', 'k77'),
                ('缓存盘', 'k78'), ('背板', 'k79'), ('传感器', 'k80'), ('RISER卡', 'k81'),
                ('主板', 'k82'), ('电源', 'k83'), ('尾纤', 'k84'), ('整机', 'k85')
            ]
            
            # Generate base text
            k_zte_storage_trust2_text = f"可信2资源池{counters8['sum_zte_storage_trust2']}台中兴存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters8[key] > 0:
                    component_texts.append(f"{counters8[key]}个{name}, ")
            
            full_text_k_zte_storage_trust2_text = k_zte_storage_trust2_text + ''.join(component_texts)
        else:                
            full_text_k_zte_storage_trust2_text = ''


        #2期超聚变dmz---------------------------------------------------------------------------------------------
        if counters9['sum2_xfusion_computer_dmz'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'l70'), ('cpu', 'l71'), ('网卡', 'l72'), ('PCIE卡', 'l73'),
                ('raid卡', 'l74'), ('风扇', 'l75'), ('光模块', 'l76'), ('内存', 'l77'),
                ('缓存盘', 'l78'), ('背板', 'l79'), ('传感器', 'l80'), ('RISER卡', 'l81'),
                ('主板', 'l82'), ('电源', 'l83'), ('尾纤', 'l84'), ('整机', 'l85')
            ]
            
            # Generate base text
            l_xfusion_computer_dmz_text = f"dmz资源池{counters9['sum2_xfusion_computer_dmz']}台超聚变计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters9[key] > 0:
                    component_texts.append(f"{counters9[key]}个{name}, ")
            
            full_text_l_xfusion_computer_dmz_text = l_xfusion_computer_dmz_text + ''.join(component_texts)            
        else:               
            full_text_l_xfusion_computer_dmz_text = ''
        #2期超聚变可信1
        if counters10['sum2_xfusion_computer_trust1'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'm70'), ('cpu', 'm71'), ('网卡', 'm72'), ('PCIE卡', 'm73'),
                ('raid卡', 'm74'), ('风扇', 'm75'), ('光模块', 'm76'), ('内存', 'm77'),
                ('缓存盘', 'm78'), ('背板', 'm79'), ('传感器', 'm80'), ('RISER卡', 'm81'),
                ('主板', 'm82'), ('电源', 'm83'), ('尾纤', 'm84'), ('整机', 'm85')
            ]
            
            # Generate base text
            m_xfusion_computer_trust1_text = f"可信1资源池{counters10['sum2_xfusion_computer_trust1']}台超聚变计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters10[key] > 0:
                    component_texts.append(f"{counters10[key]}个{name}, ")
            
            full_text_m_xfusion_computer_trust1_text = m_xfusion_computer_trust1_text + ''.join(component_texts)            
        else:            
            full_text_m_xfusion_computer_trust1_text = ''
        #2期超聚变可信2
        if counters11['sum2_xfusion_computer_trust2'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'n70'), ('cpu', 'n71'), ('网卡', 'n72'), ('PCIE卡', 'n73'),
                ('raid卡', 'n74'), ('风扇', 'n75'), ('光模块', 'n76'), ('内存', 'n77'),
                ('缓存盘', 'n78'), ('背板', 'n79'), ('传感器', 'n80'), ('RISER卡', 'n81'),
                ('主板', 'n82'), ('电源', 'n83'), ('尾纤', 'n84'), ('整机', 'n85')
            ]
            
            # Generate base text
            n_xfusion_computer_trust2_text = f"可信2资源池{counters11['sum2_xfusion_computer_trust2']}台超聚变计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters11[key] > 0:
                    component_texts.append(f"{counters11[key]}个{name}, ")
            
            full_text_n_xfusion_computer_trust2_text = n_xfusion_computer_trust2_text + ''.join(component_texts)            
        else:            
            full_text_n_xfusion_computer_trust2_text = ''
        #2期超聚变可信3
        if counters12['sum2_xfusion_computer_trust3'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'o70'), ('cpu', 'o71'), ('网卡', 'o72'), ('PCIE卡', 'o73'),
                ('raid卡', 'o74'), ('风扇', 'o75'), ('光模块', 'o76'), ('内存', 'o77'),
                ('缓存盘', 'o78'), ('背板', 'o79'), ('传感器', 'o80'), ('RISER卡', 'o81'),
                ('主板', 'o82'), ('电源', 'o83'), ('尾纤', 'o84'), ('整机', 'o85')
            ]
            
            # Generate base text
            o_xfusion_computer_trust3_text = f"可信3资源池{counters12['sum2_xfusion_computer_trust3']}台超聚变计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters12[key] > 0:
                    component_texts.append(f"{counters12[key]}个{name}, ")
            
            full_text_o_xfusion_computer_trust3_text = o_xfusion_computer_trust3_text + ''.join(component_texts)            
        else:            
            full_text_o_xfusion_computer_trust3_text = ''
        #2期超聚变可信4
        if counters13['sum2_xfusion_computer_trust4'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'p70'), ('cpu', 'p71'), ('网卡', 'p72'), ('PCIE卡', 'p73'),
                ('raid卡', 'p74'), ('风扇', 'p75'), ('光模块', 'p76'), ('内存', 'p77'),
                ('缓存盘', 'p78'), ('背板', 'p79'), ('传感器', 'p80'), ('RISER卡', 'p81'),
                ('主板', 'p82'), ('电源', 'p83'), ('尾纤', 'p84'), ('整机', 'p85')
            ]
            
            # Generate base text
            p_xfusion_computer_trust4_text = f"可信4资源池{counters13['sum2_xfusion_computer_trust4']}台超聚变计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters13[key] > 0:
                    component_texts.append(f"{counters13[key]}个{name}, ")
            
            full_text_p_xfusion_computer_trust4_text = p_xfusion_computer_trust4_text + ''.join(component_texts)            
        else:            
            full_text_p_xfusion_computer_trust4_text = ''
        #2期超聚变可信5
        if counters14['sum2_xfusion_computer_trust5'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'q70'), ('cpu', 'q71'), ('网卡', 'q72'), ('PCIE卡', 'q73'),
                ('raid卡', 'q74'), ('风扇', 'q75'), ('光模块', 'q76'), ('内存', 'q77'),
                ('缓存盘', 'q78'), ('背板', 'q79'), ('传感器', 'q80'), ('RISER卡', 'q81'),
                ('主板', 'q82'), ('电源', 'q83'), ('尾纤', 'q84'), ('整机', 'q85')
            ]
            
            # Generate base text
            q_xfusion_computer_trust5_text = f"可信5资源池{counters14['sum2_xfusion_computer_trust5']}台超聚变计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters14[key] > 0:
                    component_texts.append(f"{counters14[key]}个{name}, ")
            
            full_text_q_xfusion_computer_trust5_text = q_xfusion_computer_trust5_text  + ''.join(component_texts)            
        else:            
            full_text_q_xfusion_computer_trust5_text = ''
        #2期超聚变网管6
        if counters15['sum2_xfusion_computer_wg6'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'r70'), ('cpu', 'r71'), ('网卡', 'r72'), ('PCIE卡', 'r73'),
                ('raid卡', 'r74'), ('风扇', 'r75'), ('光模块', 'r76'), ('内存', 'r77'),
                ('缓存盘', 'r78'), ('背板', 'r79'), ('传感器', 'r80'), ('RISER卡', 'r81'),
                ('主板', 'r82'), ('电源', 'r83'), ('尾纤', 'r84'), ('整机', 'r85')
            ]
            
            # Generate base text
            r_xfusion_computer_wg6_text = f"网管6资源池{counters15['sum2_xfusion_computer_wg6']}台超聚变计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters15[key] > 0:
                    component_texts.append(f"{counters15[key]}个{name}, ")
            
            full_text_r_xfusion_computer_wg6_text = r_xfusion_computer_wg6_text  + ''.join(component_texts)            
        else:            
            full_text_r_xfusion_computer_wg6_text = ''
        #2期华为dmz
        if counters16['sum2_huawei_storage_dmz'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 's70'), ('cpu', 's71'), ('网卡', 's72'), ('PCIE卡', 's73'),
                ('raid卡', 's74'), ('风扇', 's75'), ('光模块', 's76'), ('内存', 's77'),
                ('缓存盘', 's78'), ('背板', 's79'), ('传感器', 's80'), ('RISER卡', 's81'),
                ('主板', 's82'), ('电源', 's83'), ('尾纤', 's84'), ('整机', 's85')
            ]
            
            # Generate base text
            s_huawei_storage_dmz_text = f"dmz资源池{counters16['sum2_huawei_storage_dmz']}台华为存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters16[key] > 0:
                    component_texts.append(f"{counters16[key]}个{name}, ")
            
            full_text_s_huawei_storage_dmz_text= s_huawei_storage_dmz_text  + ''.join(component_texts)            
        else:            
            full_text_s_huawei_storage_dmz_text = ''
        #2期华为可信1
        if counters17['sum2_huawei_storage_trust1'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 't70'), ('cpu', 't71'), ('网卡', 't72'), ('PCIE卡', 't73'),
                ('raid卡', 't74'), ('风扇', 't75'), ('光模块', 't76'), ('内存', 't77'),
                ('缓存盘', 't78'), ('背板', 't79'), ('传感器', 't80'), ('RISER卡', 't81'),
                ('主板', 't82'), ('电源', 't83'), ('尾纤', 't84'), ('整机', 't85')
            ]
            
            # Generate base text
            t_huawei_storage_trust1_text = f"可信1资源池{counters17['sum2_huawei_storage_trust1']}台华为存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters17[key] > 0:
                    component_texts.append(f"{counters17[key]}个{name}, ")
            
            full_text_t_huawei_storage_trust1_text= t_huawei_storage_trust1_text  + ''.join(component_texts)            
        else:            
            full_text_t_huawei_storage_trust1_text = ''
        #2期华为可信3
        if counters18['sum2_huawei_storage_trust3'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'u70'), ('cpu', 'u71'), ('网卡', 'u72'), ('PCIE卡', 'u73'),
                ('raid卡', 'u74'), ('风扇', 'u75'), ('光模块', 'u76'), ('内存', 'u77'),
                ('缓存盘', 'u78'), ('背板', 'u79'), ('传感器', 'u80'), ('RISER卡', 'u81'),
                ('主板', 'u82'), ('电源', 'u83'), ('尾纤', 'u84'), ('整机', 'u85')
            ]
            
            # Generate base text
            u_huawei_storage_trust3_text = f"可信3资源池{counters18['sum2_huawei_storage_trust3']}台华为存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters18[key] > 0:
                    component_texts.append(f"{counters18[key]}个{name}, ")
            
            full_text_u_huawei_storage_trust3_text= u_huawei_storage_trust3_text  + ''.join(component_texts)            
        else:            
            full_text_u_huawei_storage_trust3_text = ''
        #2期华为可信4
        if counters19['sum2_huawei_storage_trust4'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'v70'), ('cpu', 'v71'), ('网卡', 'v72'), ('PCIE卡', 'v73'),
                ('raid卡', 'v74'), ('风扇', 'v75'), ('光模块', 'v76'), ('内存', 'v77'),
                ('缓存盘', 'v78'), ('背板', 'v79'), ('传感器', 'v80'), ('RISER卡', 'v81'),
                ('主板', 'v82'), ('电源', 'v83'), ('尾纤', 'v84'), ('整机', 'v85')
            ]
            
            # Generate base text
            v_huawei_storage_trust4_text = f"可信4资源池{counters19['sum2_huawei_storage_trust4']}台华为存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters19[key] > 0:
                    component_texts.append(f"{counters19[key]}个{name}, ")
            
            full_text_v_huawei_storage_trust4_text= v_huawei_storage_trust4_text  + ''.join(component_texts)            
        else:            
            full_text_v_huawei_storage_trust4_text = ''
        #2期中兴存储可信2
        if counters20['sum2_zte_storage_trust2'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'w70'), ('cpu', 'w71'), ('网卡', 'w72'), ('PCIE卡', 'w73'),
                ('raid卡', 'w74'), ('风扇', 'w75'), ('光模块', 'w76'), ('内存', 'w77'),
                ('缓存盘', 'w78'), ('背板', 'w79'), ('传感器', 'w80'), ('RISER卡', 'w81'),
                ('主板', 'w82'), ('电源', 'w83'), ('尾纤', 'w84'), ('整机', 'w85')
            ]
            
            # Generate base text
            w_zte_storage_trust2_text = f"可信2资源池{counters20['sum2_zte_storage_trust2']}台中兴存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters20[key] > 0:
                    component_texts.append(f"{counters20[key]}个{name}, ")
            
            full_text_w_zte_storage_trust2_text= w_zte_storage_trust2_text  + ''.join(component_texts)            
        else:            
            full_text_w_zte_storage_trust2_text = ''
        #2期浪潮存储可信5
        if counters21['sum2_inspur_storage_trust5'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'x70'), ('cpu', 'x71'), ('网卡', 'x72'), ('PCIE卡', 'x73'),
                ('raid卡', 'x74'), ('风扇', 'x75'), ('光模块', 'x76'), ('内存', 'x77'),
                ('缓存盘', 'x78'), ('背板', 'x79'), ('传感器', 'x80'), ('RISER卡', 'x81'),
                ('主板', 'x82'), ('电源', 'x83'), ('尾纤', 'x84'), ('整机', 'x85')
            ]
            
            # Generate base text
            x_inspur_storage_trust5_text = f"可信5资源池{counters21['sum2_inspur_storage_trust5']}台浪潮存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters21[key] > 0:
                    component_texts.append(f"{counters21[key]}个{name}, ")
            
            full_text_x_inspur_storage_trust5_text= x_inspur_storage_trust5_text  + ''.join(component_texts)            
        else:            
            full_text_x_inspur_storage_trust5_text = ''
        #2期新华三
        if counters2['sum2_h3'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'e70'), ('cpu', 'e71'), ('网卡', 'e72'), ('PCIE卡', 'e73'),
                ('raid卡', 'e74'), ('风扇', 'e75'), ('光模块', 'e76'), ('内存', 'e77'),
                ('缓存盘', 'e78'), ('背板', 'e79'), ('传感器', 'e80'), ('RISER卡', 'e81'),
                ('主板', 'e82'), ('电源', 'e83'), ('尾纤', 'e84'), ('整机', 'e85')
            ]
            
            # Generate base text
            e_h3_text = f"网管6资源池{counters2['sum2_h3']}台华三存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters2[key] > 0:
                    component_texts.append(f"{counters2[key]}个{name}, ")
            
            full_text_e_h3_text = e_h3_text + ''.join(component_texts)            
        else:            
            full_text_e_h3_text = ''
        #3期中兴计算dmz---------------------------------------------------------------------------------------------
        if counters22['sum3_zte_computer_dmz'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'ee70'), ('cpu', 'ee71'), ('网卡', 'ee72'), ('PCIE卡', 'ee73'),
                ('raid卡', 'ee74'), ('风扇', 'ee75'), ('光模块', 'ee76'), ('内存', 'ee77'),
                ('缓存盘', 'ee78'), ('背板', 'ee79'), ('传感器', 'ee80'), ('RISER卡', 'ee81'),
                ('主板', 'ee82'), ('电源', 'ee83'), ('尾纤', 'ee84'), ('整机', 'ee85')
            ]
            
            # Generate base text
            ee_zte_computer_dmz_text = f"dmz资源池{counters22['sum3_zte_computer_dmz']}台中兴计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters22[key] > 0:
                    component_texts.append(f"{counters22[key]}个{name}, ")
            
            full_text_ee_zte_computer_dmz_text = ee_zte_computer_dmz_text + ''.join(component_texts)            
        else:            
            full_text_ee_zte_computer_dmz_text = ''
        #3期中兴计算trust2
        if counters23['sum3_zte_computer_trust2'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'ff70'), ('cpu', 'ff71'), ('网卡', 'ff72'), ('PCIE卡', 'ff73'),
                ('raid卡', 'ff74'), ('风扇', 'ff75'), ('光模块', 'ff76'), ('内存', 'ff77'),
                ('缓存盘', 'ff78'), ('背板', 'ff79'), ('传感器', 'ff80'), ('RISER卡', 'ff81'),
                ('主板', 'ff82'), ('电源', 'ff83'), ('尾纤', 'ff84'), ('整机', 'ff85')
            ]
            
            # Generate base text
            ff_zte_computer_trust2_text = f"可信2资源池{counters23['sum3_zte_computer_trust2']}台中兴计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters23[key] > 0:
                    component_texts.append(f"{counters23[key]}个{name}, ")
            
            full_text_ff_zte_computer_trust2_text = ff_zte_computer_trust2_text + ''.join(component_texts)            
        else:            
            full_text_ff_zte_computer_trust2_text = ''
        #3期中兴计算trust4
        if counters24['sum3_zte_computer_trust4'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'gg70'), ('cpu', 'gg71'), ('网卡', 'gg72'), ('PCIE卡', 'gg73'),
                ('raid卡', 'gg74'), ('风扇', 'gg75'), ('光模块', 'gg76'), ('内存', 'gg77'),
                ('缓存盘', 'gg78'), ('背板', 'gg79'), ('传感器', 'gg80'), ('RISER卡', 'gg81'),
                ('主板', 'gg82'), ('电源', 'gg83'), ('尾纤', 'gg84'), ('整机', 'gg85')
            ]
            
            # Generate base text
            gg_zte_computer_trust4_text = f"可信4资源池{counters24['sum3_zte_computer_trust4']}台中兴计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters24[key] > 0:
                    component_texts.append(f"{counters24[key]}个{name}, ")
            
            full_text_gg_zte_computer_trust4_text = gg_zte_computer_trust4_text + ''.join(component_texts)            
        else:            
            full_text_gg_zte_computer_trust4_text = ''
        #3期中兴计算trust5
        if counters25['sum3_zte_computer_trust5'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'hh70'), ('cpu', 'hh71'), ('网卡', 'hh72'), ('PCIE卡', 'hh73'),
                ('raid卡', 'hh74'), ('风扇', 'hh75'), ('光模块', 'hh76'), ('内存', 'hh77'),
                ('缓存盘', 'hh78'), ('背板', 'hh79'), ('传感器', 'hh80'), ('RISER卡', 'hh81'),
                ('主板', 'hh82'), ('电源', 'hh83'), ('尾纤', 'hh84'), ('整机', 'hh85')
            ]
            
            # Generate base text
            hh_zte_computer_trust5_text = f"可信5资源池{counters25['sum3_zte_computer_trust5']}台中兴计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters25[key] > 0:
                    component_texts.append(f"{counters25[key]}个{name}, ")
            
            full_text_hh_zte_computer_trust5_text = hh_zte_computer_trust5_text + ''.join(component_texts)            
        else:            
            full_text_hh_zte_computer_trust5_text = ''
        #3期中兴计算wg6
        if counters26['sum3_zte_computer_wg6'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'ii70'), ('cpu', 'ii71'), ('网卡', 'ii72'), ('PCIE卡', 'ii73'),
                ('raid卡', 'ii74'), ('风扇', 'ii75'), ('光模块', 'ii76'), ('内存', 'ii77'),
                ('缓存盘', 'ii78'), ('背板', 'ii79'), ('传感器', 'ii80'), ('RISER卡', 'ii81'),
                ('主板', 'ii82'), ('电源', 'ii83'), ('尾纤', 'ii84'), ('整机', 'ii85')
            ]
            
            # Generate base text
            ii_zte_computer_wg6_text = f"网管6资源池{counters26['sum3_zte_computer_wg6']}台中兴计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters26[key] > 0:
                    component_texts.append(f"{counters26[key]}个{name}, ")
            
            full_text_ii_zte_computer_wg6_text = ii_zte_computer_wg6_text + ''.join(component_texts)            
        else:            
            full_text_ii_zte_computer_wg6_text = ''
        #3期中兴存储可信2
        if counters27['sum3_zte_storage_trust2'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'jj70'), ('cpu', 'jj71'), ('网卡', 'jj72'), ('PCIE卡', 'jj73'),
                ('raid卡', 'jj74'), ('风扇', 'jj75'), ('光模块', 'jj76'), ('内存', 'jj77'),
                ('缓存盘', 'jj78'), ('背板', 'jj79'), ('传感器', 'jj80'), ('RISER卡', 'jj81'),
                ('主板', 'jj82'), ('电源', 'jj83'), ('尾纤', 'jj84'), ('整机', 'jj85')
            ]
            
            # Generate base text
            jj_zte_storage_trust2_text = f"可信2资源池{counters27['sum3_zte_storage_trust2']}台中兴存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters27[key] > 0:
                    component_texts.append(f"{counters27[key]}个{name}, ")
            
            full_text_jj_zte_storage_trust2_text = jj_zte_storage_trust2_text + ''.join(component_texts)            
        else:            
            full_text_jj_zte_storage_trust2_text = ''
        #3期中兴存储可信7
        if counters28['sum3_zte_storage_trust7'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'kk70'), ('cpu', 'kk71'), ('网卡', 'kk72'), ('PCIE卡', 'kk73'),
                ('raid卡', 'kk74'), ('风扇', 'kk75'), ('光模块', 'kk76'), ('内存', 'kk77'),
                ('缓存盘', 'kk78'), ('背板', 'kk79'), ('传感器', 'kk80'), ('RISER卡', 'kk81'),
                ('主板', 'kk82'), ('电源', 'kk83'), ('尾纤', 'kk84'), ('整机', 'kk85')
            ]
            
            # Generate base text
            kk_zte_storage_trust7_text = f"可信7资源池{counters28['sum3_zte_storage_trust7']}台中兴存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters28[key] > 0:
                    component_texts.append(f"{counters28[key]}个{name}, ")
            
            full_text_kk_zte_storage_trust7_text = kk_zte_storage_trust7_text + ''.join(component_texts)            
        else:             
            full_text_kk_zte_storage_trust7_text = ''
        #3期新华三存储wg6
        if counters29['sum3_h3c_storage_wg6'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'll70'), ('cpu', 'll71'), ('网卡', 'll72'), ('PCIE卡', 'll73'),
                ('raid卡', 'll74'), ('风扇', 'll75'), ('光模块', 'll76'), ('内存', 'll77'),
                ('缓存盘', 'll78'), ('背板', 'll79'), ('传感器', 'll80'), ('RISER卡', 'll81'),
                ('主板', 'll82'), ('电源', 'll83'), ('尾纤', 'll84'), ('整机', 'll85')
            ]
            
            # Generate base text
            ll_h3c_storage_wg6_text = f"网管6资源池{counters29['sum3_h3c_storage_wg6']}台新华三存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters29[key] > 0:
                    component_texts.append(f"{counters29[key]}个{name}, ")
            
            full_text_ll_h3c_storage_wg6_text = ll_h3c_storage_wg6_text + ''.join(component_texts)            
        else:            
            full_text_ll_h3c_storage_wg6_text = ''
        #3期浪潮计算wg6
        if counters30['sum3_inspur_computer_wg6'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'mm70'), ('cpu', 'mm71'), ('网卡', 'mm72'), ('PCIE卡', 'mm73'),
                ('raid卡', 'mm74'), ('风扇', 'mm75'), ('光模块', 'mm76'), ('内存', 'mm77'),
                ('缓存盘', 'mm78'), ('背板', 'mm79'), ('传感器', 'mm80'), ('RISER卡', 'mm81'),
                ('主板', 'mm82'), ('电源', 'mm83'), ('尾纤', 'mm84'), ('整机', 'mm85')
            ]
            
            # Generate base text
            mm_inspur_computer_wg6_text = f"wg6资源池{counters30['sum3_inspur_computer_wg6']}台浪潮计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters30[key] > 0:
                    component_texts.append(f"{counters30[key]}个{name}, ")
            
            full_text_mm_inspur_computer_wg6_text = mm_inspur_computer_wg6_text + ''.join(component_texts)            
        else:            
            full_text_mm_inspur_computer_wg6_text = ''
        #3期浪潮计算可信7
        if counters31['sum3_inspur_computer_trust7'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'nn70'), ('cpu', 'nn71'), ('网卡', 'nn72'), ('PCIE卡', 'nn73'),
                ('raid卡', 'nn74'), ('风扇', 'nn75'), ('光模块', 'nn76'), ('内存', 'nn77'),
                ('缓存盘', 'nn78'), ('背板', 'nn79'), ('传感器', 'nn80'), ('RISER卡', 'nn81'),
                ('主板', 'nn82'), ('电源', 'nn83'), ('尾纤', 'nn84'), ('整机', 'nn85')
            ]
            
            # Generate base text
            nn_inspur_computer_trust7_text = f"可信7资源池{counters31['sum3_inspur_computer_trust7']}台浪潮计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters31[key] > 0:
                    component_texts.append(f"{counters31[key]}个{name}, ")
            
            full_text_nn_inspur_computer_trust7_text = nn_inspur_computer_trust7_text + ''.join(component_texts)            
        else:                   
            full_text_nn_inspur_computer_trust7_text = ''
        #3期浪潮存储可信5
        if counters32['sum3_inspur_storage_trust5'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'oo70'), ('cpu', 'oo71'), ('网卡', 'oo72'), ('PCIE卡', 'oo73'),
                ('raid卡', 'oo74'), ('风扇', 'oo75'), ('光模块', 'oo76'), ('内存', 'oo77'),
                ('缓存盘', 'oo78'), ('背板', 'oo79'), ('传感器', 'oo80'), ('RISER卡', 'oo81'),
                ('主板', 'oo82'), ('电源', 'oo83'), ('尾纤', 'oo84'), ('整机', 'oo85')
            ]
            
            # Generate base text
            oo_inspur_storage_trust5_text = f"可信5资源池{counters32['sum3_inspur_storage_trust5']}台浪潮存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters32[key] > 0:
                    component_texts.append(f"{counters32[key]}个{name}, ")
            
            full_text_oo_inspur_storage_trust5_text = oo_inspur_storage_trust5_text + ''.join(component_texts)
        else:                
            full_text_oo_inspur_storage_trust5_text = ''
        #4期中兴计算网管6---------------------------------------------------------------------------------------------
        if counters33['sum4_zte_computer_wg6'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'pp70'), ('cpu', 'pp71'), ('网卡', 'pp72'), ('PCIE卡', 'pp73'),
                ('raid卡', 'pp74'), ('风扇', 'pp75'), ('光模块', 'pp76'), ('内存', 'pp77'),
                ('缓存盘', 'pp78'), ('背板', 'pp79'), ('传感器', 'pp80'), ('RISER卡', 'pp81'),
                ('主板', 'pp82'), ('电源', 'pp83'), ('尾纤', 'pp84'), ('整机', 'pp85')
            ]
            
            # Generate base text
            pp_zte_computer_wg6_text = f"网管6资源池{counters33['sum4_zte_computer_wg6']}台中兴计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters33[key] > 0:
                    component_texts.append(f"{counters33[key]}个{name}, ")
            
            full_text_pp_zte_computer_wg6_text = pp_zte_computer_wg6_text + ''.join(component_texts)            
        else:            
            full_text_pp_zte_computer_wg6_text = ''
        #4期中兴计算可信8
        if counters34['sum4_zte_computer_trust8'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'qq70'), ('cpu', 'qq71'), ('网卡', 'qq72'), ('PCIE卡', 'qq73'),
                ('raid卡', 'qq74'), ('风扇', 'qq75'), ('光模块', 'qq76'), ('内存', 'qq77'),
                ('缓存盘', 'qq78'), ('背板', 'qq79'), ('传感器', 'qq80'), ('RISER卡', 'qq81'),
                ('主板', 'qq82'), ('电源', 'qq83'), ('尾纤', 'qq84'), ('整机', 'qq85')
            ]
            
            # Generate base text
            qq_zte_computer_trust8_text = f"网管6资源池{counters34['sum4_zte_computer_trust8']}台中兴计算服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters34[key] > 0:
                    component_texts.append(f"{counters34[key]}个{name}, ")
            
            full_text_qq_zte_computer_trust8_text = qq_zte_computer_trust8_text + ''.join(component_texts)            
        else:            
            full_text_qq_zte_computer_trust8_text = ''
        #4期浪潮存储可信8
        if counters35['sum4_inspur_storage_trust8'] > 0:
            # Define component names and their corresponding counter keys
            components = [
                ('硬盘', 'rr70'), ('cpu', 'rr71'), ('网卡', 'rr72'), ('PCIE卡', 'rr73'),
                ('raid卡', 'rr74'), ('风扇', 'rr75'), ('光模块', 'rr76'), ('内存', 'rr77'),
                ('缓存盘', 'rr78'), ('背板', 'rr79'), ('传感器', 'rr80'), ('RISER卡', 'rr81'),
                ('主板', 'rr82'), ('电源', 'rr83'), ('尾纤', 'rr84'), ('整机', 'rr85')
            ]
            
            # Generate base text
            rr_inspur_storage_trust8_text = f"可信8资源池{counters35['sum4_inspur_storage_trust8']}台浪潮存储服务器"
            
            # Generate component texts
            component_texts = []
            for name, key in components:
                if counters35[key] > 0:
                    component_texts.append(f"{counters35[key]}个{name}, ")
            
            full_text_rr_inspur_storage_trust8_text = rr_inspur_storage_trust8_text + ''.join(component_texts)
        else:                
            full_text_rr_inspur_storage_trust8_text = ''

        # 使用字典的get方法获取值，若键不存在则返回默认值0，避免KeyError异常
        str_the_first_phase = str(counters.get('the_first_phase', 0))   # 一期dmz，可信1，可信2设备故障总和
        str_the_second_phase = str(counters.get('the_second_phase', 0)) # 二期dmz，可信1，可信2，可信3，可信4，可信5，网管资源池设备故障总和
        str_the_third_phase = str(counters.get('the_third_phase', 0))   # 三期dmz，可信2，可信4，可信5，网管6，可信7资源池设备故障总和
        str_the_fourth_phase = str(counters.get('the_fourth_phase', 0)) # 四期可信8，网管资源池设备故障总和

        # #文本一，二，三，四期资源池：
        full_text_1 ='eg：\n' + '一期资源池：\n'
        full_text_2 ='二期资源池：\n'
        full_text_3 ='三期资源池：\n'
        full_text_4 ='四期资源池：\n'

        # #西北大区发现28项并处理28项问题并处理28项问题：
        full_text_1 = full_text_1 +   '西北大区发现' + str_the_first_phase +'项并处理' + str_the_first_phase + '项问题：'
        full_text_2 = full_text_2 +   '西北大区发现' + str_the_second_phase +'项并处理' + str_the_second_phase + '项问题：'
        full_text_3 = full_text_3 +   '西北大区发现' + str_the_third_phase +'项并处理' + str_the_third_phase + '项问题：'
        full_text_4 = full_text_4 +   '西北大区发现' + str_the_fourth_phase +'项并处理' + str_the_fourth_phase + '项问题：'

            
        # #网管资源池7台华三存储服务器2个硬盘、1个主板故障、1个缓存盘、1个电源等
        end_full_text_1 = full_text_1 +  full_text_f_inspur_computer_dmz_text + full_text_i_huawei_storage_dmz_text + full_text_g_inspur_computer_trust1_text + full_text_j_huawei_storage_trust1_text + full_text_h_inspur_computer_trust2_text  + full_text_k_zte_storage_trust2_text + '已完成处理；'        
        end_full_text_2 = full_text_2 + full_text_s_huawei_storage_dmz_text + full_text_l_xfusion_computer_dmz_text + full_text_m_xfusion_computer_trust1_text + full_text_t_huawei_storage_trust1_text + full_text_w_zte_storage_trust2_text + full_text_n_xfusion_computer_trust2_text + full_text_u_huawei_storage_trust3_text + full_text_o_xfusion_computer_trust3_text + full_text_v_huawei_storage_trust4_text + full_text_p_xfusion_computer_trust4_text + full_text_x_inspur_storage_trust5_text + full_text_q_xfusion_computer_trust5_text + full_text_r_xfusion_computer_wg6_text+ full_text_e_h3_text + '已完成处理；'        
        end_full_text_3 = full_text_3 +  full_text_ee_zte_computer_dmz_text +   full_text_ff_zte_computer_trust2_text + full_text_jj_zte_storage_trust2_text + full_text_gg_zte_computer_trust4_text +  full_text_hh_zte_computer_trust5_text + full_text_oo_inspur_storage_trust5_text + full_text_ii_zte_computer_wg6_text + full_text_ll_h3c_storage_wg6_text + full_text_mm_inspur_computer_wg6_text + full_text_kk_zte_storage_trust7_text + full_text_nn_inspur_computer_trust7_text +  '已完成处理；'
        end_full_text_4 = full_text_4 +  full_text_pp_zte_computer_wg6_text + full_text_qq_zte_computer_trust8_text + full_text_rr_inspur_storage_trust8_text + '已完成处理；'


        # 将生成的文本插入到合并单元格A113中
        ##这里一定要注意，合并单元格要和excel对应，目前是A112，如果上下错行，需要在程序里修改A11？ 
        sheet['A116'].value = end_full_text_1 + '\n' + end_full_text_2 + '\n' + end_full_text_3  + '\n' + end_full_text_4
        # 设置A112单元格自动换行，确保长文本能完整显示
        sheet['A116'].alignment = Alignment(wrap_text=True)
            

	    # 日期格式处理 ----------------------------------------
        # # 创建日期样式（避免重复创建）
        if 'date_style' not in workbook.named_styles:
           date_style = openpyxl.styles.NamedStyle(name='date_style', number_format='YYYY-MM-DD')
           workbook.add_named_style(date_style)
    
        # 处理E列（故障发生时间）和F列（告警清除时间）
        # 遍历Excel表格中第3到39行，第5到6列（E列和F列）的单元格
        for row in sheet.iter_rows(min_row=3, max_row=56, min_col=5, max_col=6):
            for cell in row:
                 # 检查单元格值是否是datetime对象或字符串类型
                 if isinstance(cell.value, (datetime.datetime, str)):
                     try:
                         # 如果值是字符串类型，尝试转换为datetime对象
                         if isinstance(cell.value, str):
                             # 使用strptime按照"年/月/日 时:分"的格式解析字符串
                             dt_value = datetime.datetime.strptime(cell.value, "%Y/%m/%d %H:%M")
                             # 将转换后的datetime对象赋值回单元格
                             cell.value = dt_value
                             # 应用预设的日期样式（YYYY-MM-DD格式）
                             cell.style = 'date_style'
                     except ValueError:
                         # 如果日期解析失败，打印错误信息并保持原格式
                         print(f"无法解析日期: {cell.value}，保持原格式")
       
       
       # 保存最终文件
        workbook.save(file_path)
        
        # 保存数据到数据库
        try:
            # 保存故障明细数据
            print(f"准备保存 {len(fault_details)} 条故障明细数据到数据库")
            save_fault_details_to_database(fault_details)
            
            # 保存故障统计数据
            save_fault_data_to_database(counters, counters1)
            
            # 保存详细故障描述
            detailed_description = end_full_text_1 + '\n' + end_full_text_2 + '\n' + end_full_text_3  + '\n' + end_full_text_4
            save_fault_description_to_database(detailed_description)
        except Exception as e:
            print(f"保存数据到数据库时出错: {str(e)}")
        
        print(f"中间函数调用：文件修改完成，已保存到: {file_path}")
        return file_path
    except FileNotFoundError as e:
        print(f"错误: {e}")
        print("请检查文件路径是否正确，或文件是否存在于指定位置。")
        raise
    except Exception as e:
        print(f"修改Excel文件时出错: {str(e)}")
        raise
